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
# # 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 storage::hp::p2000::xmlapi::custom; use strict; use warnings; use centreon::plugins::http; use XML::XPath; use Digest::MD5 qw(md5_hex); sub new { my ($class, %options) = @_; my $self = {}; bless $self, $class; # $options{options} = options object # $options{output} = output object # $options{exit_value} = integer # $options{noptions} = integer 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', }, "port:s@" => { name => 'port', }, "proto:s@" => { name => 'proto', }, "urlpath:s@" => { name => 'url_path', }, "proxyurl:s@" => { name => 'proxyurl', }, "username:s@" => { name => 'username', }, "password:s@" => { name => 'password', }, "timeout:s@" => { name => 'timeout', }, }); } $options{options}->add_help(package => __PACKAGE__, sections => 'P2000 OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; $self->{session_id} = ''; $self->{logon} = 0; return $self; } # Method to manage multiples sub set_options { my ($self, %options) = @_; # options{options_result} $self->{option_results} = $options{option_results}; } # Method to manage multiples sub set_defaults { my ($self, %options) = @_; # options{default} # Manage default value 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) = @_; # return 1 = ok still hostname # return 0 = no hostname left $self->{hostname} = (defined($self->{option_results}->{hostname})) ? shift(@{$self->{option_results}->{hostname}}) : undef; $self->{username} = (defined($self->{option_results}->{username})) ? shift(@{$self->{option_results}->{username}}) : undef; $self->{password} = (defined($self->{option_results}->{password})) ? shift(@{$self->{option_results}->{password}}) : undef; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 45; $self->{port} = (defined($self->{option_results}->{port})) ? shift(@{$self->{option_results}->{port}}) : undef; $self->{proto} = (defined($self->{option_results}->{proto})) ? shift(@{$self->{option_results}->{proto}}) : 'http'; $self->{url_path} = (defined($self->{option_results}->{url_path})) ? shift(@{$self->{option_results}->{url_path}}) : '/api/'; $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? shift(@{$self->{option_results}->{proxyurl}}) : undef; if (!defined($self->{hostname})) { $self->{output}->add_option_msg(short_msg => "Need to specify hostname option."); $self->{output}->option_exit(); } if (!defined($self->{username}) || !defined($self->{password})) { $self->{output}->add_option_msg(short_msg => 'Need to specify username or/and password option.'); $self->{output}->option_exit(); } if (!defined($self->{hostname}) || scalar(@{$self->{option_results}->{hostname}}) == 0) { return 0; } return 1; } sub build_options_for_httplib { my ($self, %options) = @_; $self->{option_results}->{hostname} = $self->{hostname}; $self->{option_results}->{timeout} = $self->{timeout}; $self->{option_results}->{port} = $self->{port}; $self->{option_results}->{proto} = $self->{proto}; $self->{option_results}->{url_path} = $self->{url_path}; $self->{option_results}->{proxyurl} = $self->{proxyurl}; } sub check_login { my ($self, %options) = @_; my ($xpath, $nodeset); eval { $xpath = XML::XPath->new(xml => $options{content}); $nodeset = $xpath->find("//OBJECT[\@basetype='status']//PROPERTY[\@name='return-code']"); }; if ($@) { $self->{output}->add_option_msg(short_msg => "Cannot parse login response: $@"); $self->{output}->option_exit(); } if (scalar($nodeset->get_nodelist) == 0) { $self->{output}->output_add(severity => 'UNKNOWN', short_msg => 'Cannot find login response.'); $self->{output}->display(); $self->{output}->exit(); } foreach my $node ($nodeset->get_nodelist()) { if ($node->string_value != 1) { $self->{output}->output_add(severity => 'UNKNOWN', short_msg => 'Login authentification failed (return-code: ' . $node->string_value . ').'); $self->{output}->display(); $self->{output}->exit(); } } $nodeset = $xpath->find("//OBJECT[\@basetype='status']//PROPERTY[\@name='response']"); my @nodes = $nodeset->get_nodelist(); my $node = shift(@nodes); $self->{session_id} = $node->string_value; $self->{logon} = 1; } sub DESTROY { my $self = shift; if ($self->{logon} == 1) { $self->{http}->request(url_path => $self->{url_path} . 'exit', header => ['Cookie: wbisessionkey=' . $self->{session_id} . '; wbiusername=' . $self->{username}, 'dataType: api', 'sessionKey: '. $self->{session_id}]); } } sub get_infos { my ($self, %options) = @_; my ($xpath, $nodeset); my $cmd = $options{cmd}; $cmd =~ s/ /\//g; my $response =$self->{http}->request(url_path => $self->{url_path} . $cmd, header => ['Cookie: wbisessionkey=' . $self->{session_id} . '; wbiusername=' . $self->{username}, 'dataType: api', 'sessionKey: '. $self->{session_id}]); eval { $xpath = XML::XPath->new(xml => $response); $nodeset = $xpath->find("//OBJECT[\@basetype='" . $options{base_type} . "']"); }; if ($@) { $self->{output}->add_option_msg(short_msg => "Cannot parse 'cmd' response: $@"); $self->{output}->option_exit(); } # Check if there is an error #<OBJECT basetype="status" name="status" oid="1"> #<PROPERTY name="response-type" type="enumeration" size="12" draw="false" sort="nosort" display-name="Response Type">Error</PROPERTY> #<PROPERTY name="response-type-numeric" type="enumeration" size="12" draw="false" sort="nosort" display-name="Response">1</PROPERTY> #<PROPERTY name="response" type="string" size="180" draw="true" sort="nosort" display-name="Response">The command is ambiguous. Please check the help for this command.</PROPERTY> #<PROPERTY name="return-code" type="int32" size="5" draw="false" sort="nosort" display-name="Return Code">-10028</PROPERTY> #<PROPERTY name="component-id" type="string" size="80" draw="false" sort="nosort" display-name="Component ID"></PROPERTY> #</OBJECT> if (my $nodestatus = $xpath->find("//OBJECT[\@basetype='status']//PROPERTY[\@name='return-code']")) { my @nodes = $nodestatus->get_nodelist(); my $node = shift @nodes; my $return_code = $node->string_value; if ($return_code != 0) { $nodestatus = $xpath->find("//OBJECT[\@basetype='status']//PROPERTY[\@name='response']"); @nodes = $nodestatus->get_nodelist(); $node = shift @nodes; $self->{output}->add_option_msg(short_msg => $node->string_value); $self->{output}->option_exit(); } } my $results = {}; foreach my $node ($nodeset->get_nodelist()) { my $properties = {}; foreach my $prop_node ($node->getChildNodes()) { my $prop_name = $prop_node->getAttribute('name'); if (defined($prop_name) && ($prop_name eq $options{key} || $prop_name =~ /$options{properties_name}/)) { $properties->{$prop_name} = $prop_node->string_value; } } if (defined($properties->{$options{key}})) { $results->{$properties->{$options{key}}} = $properties; } } return $results; } ############## # Specific methods ############## sub login { my ($self, %options) = @_; $self->build_options_for_httplib(); $self->{http} = centreon::plugins::http->new(output => $self->{output}); $self->{http}->set_options(%{$self->{option_results}}); # Login First my $md5_hash = md5_hex($self->{username} . '_' . $self->{password}); my $response = $self->{http}->request(url_path => $self->{url_path} . 'login/' . $md5_hash); $self->check_login(content => $response); } 1; __END__ =head1 NAME MSA p2000 =head1 SYNOPSIS my p2000 xml api manage =head1 P2000 OPTIONS =over 8 =item B<--hostname> HP p2000 Hostname. =item B<--port> Port used =item B<--proxyurl> Proxy URL if any =item B<--proto> Specify https if needed =item B<--urlpath> Set path to xml api (Default: '/api/') =item B<--username> Username to connect. =item B<--password> Password to connect. =item B<--timeout> Set HTTP timeout =back =head1 DESCRIPTION B<custom>. =cut
nichols-356/centreon-plugins
storage/hp/p2000/xmlapi/custom.pm
Perl
apache-2.0
10,818
use strict; use XML::Simple; use Data::Dumper; $XML::Simple::PREFERRED_PARSER = 'XML::Parser'; my $xml_gold = XMLin($ARGV[0]); my $xml_new = XMLin($ARGV[1]); my %match; #print Dumper($xml_gold); my % attr_values; foreach my $id (sort (keys %{$xml_new->{targetInstance}})) { my $aff_path=$xml_new->{targetInstance}->{$id}->{attribute}->{AFFINITY_PATH}->{default}; foreach my $attr (sort (keys %{$xml_new->{targetInstance}->{$id}->{attribute}})) { if (ref($xml_new->{targetInstance}->{$id}->{attribute}->{$attr}->{default}) eq "HASH") { if (defined($xml_new->{targetInstance}->{$id}->{attribute}->{$attr}->{default}->{field})) { foreach my $field (sort (keys %{$xml_new->{targetInstance}->{$id}->{attribute}->{$attr}->{default}->{field}})) { my $value=$xml_new->{targetInstance}->{$id}->{attribute}->{$attr}->{default}->{field}->{$field}->{value}; my $key=$aff_path." | ".$attr."_".$field; $value=~s/\t//g; $value=~s/\s//g; $attr_values{$key}=$value; } } } else { my $value=$xml_new->{targetInstance}->{$id}->{attribute}->{$attr}->{default}; my $key=$aff_path." | ".$attr; $value=~s/\t//g; $value=~s/\s//g; $attr_values{$key}=$value; #print ">>>> $key = $value\n"; } } } foreach my $id (sort (keys %{$xml_gold->{targetInstance}})) { my $aff_path=$xml_gold->{targetInstance}->{$id}->{attribute}->{AFFINITY_PATH}->{default}; foreach my $attr (sort (keys %{$xml_gold->{targetInstance}->{$id}->{attribute}})) { if (ref($xml_gold->{targetInstance}->{$id}->{attribute}->{$attr}->{default}) eq "HASH") { if (defined($xml_gold->{targetInstance}->{$id}->{attribute}->{$attr}->{default}->{field})) { foreach my $field (sort (keys %{$xml_gold->{targetInstance}->{$id}->{attribute}->{$attr}->{default}->{field}})) { my $value=$xml_gold->{targetInstance}->{$id}->{attribute}->{$attr}->{default}->{field}->{$field}->{value}; $value=~s/\t//g; $value=~s/\s//g; my $key=$aff_path." | ".$attr."_".$field; my $newval=$attr_values{$key}; $match{$key}=1; if ($value ne $newval) { printf("%100s | %s\n%100s | %s\n\n",$key,$value,"",$newval); } if ($key=~/PHYS_PATH/) { # print "$key = $value\n"; } } } } else { my $value=$xml_gold->{targetInstance}->{$id}->{attribute}->{$attr}->{default}; $value=~s/\t//g; $value=~s/\s//g; my $key=$aff_path." | ".$attr; my $newval=$attr_values{$key}; $match{$key}=1; if ($value ne $newval) { printf("%100s | %s\n%100s | %s\n\n",$key,$value,"",$newval); } if ($key=~/PHYS_PATH/) { #print "$key = $value\n"; } } } }
alvintpwang/serverwiz
scripts/compare.pl
Perl
apache-2.0
2,637
# !!!!!!! DO NOT EDIT THIS FILE !!!!!!! # This file is machine-generated by lib/unicore/mktables from the Unicode # database, Version 6.1.0. Any changes made here will be lost! # !!!!!!! INTERNAL PERL USE ONLY !!!!!!! # This file is for internal use by core Perl only. The format and even the # name or existence of this file are subject to change without notice. Don't # use it directly. return <<'END'; 10123 END
efortuna/AndroidSDKClone
ndk_experimental/prebuilt/linux-x86_64/lib/perl5/5.16.2/unicore/lib/Nv/2000.pl
Perl
apache-2.0
431
package Object::Accessor; use strict; use Carp qw[carp croak]; use vars qw[$FATAL $DEBUG $AUTOLOAD $VERSION]; use Params::Check qw[allow]; use Data::Dumper; ### some objects might have overload enabled, we'll need to ### disable string overloading for callbacks require overload; $VERSION = '0.42'; $FATAL = 0; $DEBUG = 0; use constant VALUE => 0; # array index in the hash value use constant ALLOW => 1; # array index in the hash value use constant ALIAS => 2; # array index in the hash value =head1 NAME Object::Accessor - interface to create per object accessors =head1 SYNOPSIS ### using the object $obj = Object::Accessor->new; # create object $obj = Object::Accessor->new(@list); # create object with accessors $obj = Object::Accessor->new(\%h); # create object with accessors # and their allow handlers $bool = $obj->mk_accessors('foo'); # create accessors $bool = $obj->mk_accessors( # create accessors with input {foo => ALLOW_HANDLER} ); # validation $bool = $obj->mk_aliases( # create an alias to an existing alias_name => 'method'); # method name $clone = $obj->mk_clone; # create a clone of original # object without data $bool = $obj->mk_flush; # clean out all data @list = $obj->ls_accessors; # retrieves a list of all # accessors for this object $bar = $obj->foo('bar'); # set 'foo' to 'bar' $bar = $obj->foo(); # retrieve 'bar' again $sub = $obj->can('foo'); # retrieve coderef for # 'foo' accessor $bar = $sub->('bar'); # set 'foo' via coderef $bar = $sub->(); # retrieve 'bar' by coderef ### using the object as base class package My::Class; use base 'Object::Accessor'; $obj = My::Class->new; # create base object $bool = $obj->mk_accessors('foo'); # create accessors, etc... ### make all attempted access to non-existent accessors fatal ### (defaults to false) $Object::Accessor::FATAL = 1; ### enable debugging $Object::Accessor::DEBUG = 1; ### advanced usage -- callbacks { my $obj = Object::Accessor->new('foo'); $obj->register_callback( sub { ... } ); $obj->foo( 1 ); # these calls invoke the callback you registered $obj->foo() # which allows you to change the get/set # behaviour and what is returned to the caller. } ### advanced usage -- lvalue attributes { my $obj = Object::Accessor::Lvalue->new('foo'); print $obj->foo = 1; # will print 1 } ### advanced usage -- scoped attribute values { my $obj = Object::Accessor->new('foo'); $obj->foo( 1 ); print $obj->foo; # will print 1 ### bind the scope of the value of attribute 'foo' ### to the scope of '$x' -- when $x goes out of ### scope, 'foo's previous value will be restored { $obj->foo( 2 => \my $x ); print $obj->foo, ' ', $x; # will print '2 2' } print $obj->foo; # will print 1 } =head1 DESCRIPTION C<Object::Accessor> provides an interface to create per object accessors (as opposed to per C<Class> accessors, as, for example, C<Class::Accessor> provides). You can choose to either subclass this module, and thus using its accessors on your own module, or to store an C<Object::Accessor> object inside your own object, and access the accessors from there. See the C<SYNOPSIS> for examples. =head1 METHODS =head2 $object = Object::Accessor->new( [ARGS] ); Creates a new (and empty) C<Object::Accessor> object. This method is inheritable. Any arguments given to C<new> are passed straight to C<mk_accessors>. If you want to be able to assign to your accessors as if they were C<lvalue>s, you should create your object in the C<Object::Accessor::Lvalue> namespace instead. See the section on C<LVALUE ACCESSORS> below. =cut sub new { my $class = shift; my $obj = bless {}, $class; $obj->mk_accessors( @_ ) if @_; return $obj; } =head2 $bool = $object->mk_accessors( @ACCESSORS | \%ACCESSOR_MAP ); Creates a list of accessors for this object (and C<NOT> for other ones in the same class!). Will not clobber existing data, so if an accessor already exists, requesting to create again is effectively a C<no-op>. When providing a C<hashref> as argument, rather than a normal list, you can specify a list of key/value pairs of accessors and their respective input validators. The validators can be anything that C<Params::Check>'s C<allow> function accepts. Please see its manpage for details. For example: $object->mk_accessors( { foo => qr/^\d+$/, # digits only bar => [0,1], # booleans zot => \&my_sub # a custom verification sub } ); Returns true on success, false on failure. Accessors that are called on an object, that do not exist return C<undef> by default, but you can make this a fatal error by setting the global variable C<$FATAL> to true. See the section on C<GLOBAL VARIABLES> for details. Note that you can bind the values of attributes to a scope. This allows you to C<temporarily> change a value of an attribute, and have it's original value restored up on the end of it's bound variable's scope; For example, in this snippet of code, the attribute C<foo> will temporarily be set to C<2>, until the end of the scope of C<$x>, at which point the original value of C<1> will be restored. my $obj = Object::Accessor->new; $obj->mk_accessors('foo'); $obj->foo( 1 ); print $obj->foo; # will print 1 ### bind the scope of the value of attribute 'foo' ### to the scope of '$x' -- when $x goes out of ### scope, 'foo' previous value will be restored { $obj->foo( 2 => \my $x ); print $obj->foo, ' ', $x; # will print '2 2' } print $obj->foo; # will print 1 Note that all accessors are read/write for everyone. See the C<TODO> section for details. =cut sub mk_accessors { my $self = $_[0]; my $is_hash = UNIVERSAL::isa( $_[1], 'HASH' ); ### first argument is a hashref, which means key/val pairs ### as keys + allow handlers for my $acc ( $is_hash ? keys %{$_[1]} : @_[1..$#_] ) { ### already created apparently if( exists $self->{$acc} ) { __PACKAGE__->___debug( "Accessor '$acc' already exists"); next; } __PACKAGE__->___debug( "Creating accessor '$acc'"); ### explicitly vivify it, so that exists works in ls_accessors() $self->{$acc}->[VALUE] = undef; ### set the allow handler only if one was specified $self->{$acc}->[ALLOW] = $_[1]->{$acc} if $is_hash; } return 1; } =head2 @list = $self->ls_accessors; Returns a list of accessors that are supported by the current object. The corresponding coderefs can be retrieved by passing this list one by one to the C<can> method. =cut sub ls_accessors { ### metainformation is stored in the stringified ### key of the object, so skip that when listing accessors return sort grep { $_ ne "$_[0]" } keys %{$_[0]}; } =head2 $ref = $self->ls_allow(KEY) Returns the allow handler for the given key, which can be used with C<Params::Check>'s C<allow()> handler. If there was no allow handler specified, an allow handler that always returns true will be returned. =cut sub ls_allow { my $self = shift; my $key = shift or return; return exists $self->{$key}->[ALLOW] ? $self->{$key}->[ALLOW] : sub { 1 }; } =head2 $bool = $self->mk_aliases( alias => method, [alias2 => method2, ...] ); Creates an alias for a given method name. For all intents and purposes, these two accessors are now identical for this object. This is akin to doing the following on the symbol table level: *alias = *method This allows you to do the following: $self->mk_accessors('foo'); $self->mk_aliases( bar => 'foo' ); $self->bar( 42 ); print $self->foo; # will print 42 =cut sub mk_aliases { my $self = shift; my %aliases = @_; while( my($alias, $method) = each %aliases ) { ### already created apparently if( exists $self->{$alias} ) { __PACKAGE__->___debug( "Accessor '$alias' already exists"); next; } $self->___alias( $alias => $method ); } return 1; } =head2 $clone = $self->mk_clone; Makes a clone of the current object, which will have the exact same accessors as the current object, but without the data stored in them. =cut ### XXX this creates an object WITH allow handlers at all times. ### even if the original didnt sub mk_clone { my $self = $_[0]; my $class = ref $self; my $clone = $class->new; ### split out accessors with and without allow handlers, so we ### don't install dummy allow handers (which makes O::A::lvalue ### warn for example) my %hash; my @list; for my $acc ( $self->ls_accessors ) { my $allow = $self->{$acc}->[ALLOW]; $allow ? $hash{$acc} = $allow : push @list, $acc; ### is this an alias? if( my $org = $self->{ $acc }->[ ALIAS ] ) { $clone->___alias( $acc => $org ); } } ### copy the accessors from $self to $clone $clone->mk_accessors( \%hash ) if %hash; $clone->mk_accessors( @list ) if @list; ### copy callbacks #$clone->{"$clone"} = $self->{"$self"} if $self->{"$self"}; $clone->___callback( $self->___callback ); return $clone; } =head2 $bool = $self->mk_flush; Flushes all the data from the current object; all accessors will be set back to their default state of C<undef>. Returns true on success and false on failure. =cut sub mk_flush { my $self = $_[0]; # set each accessor's data to undef $self->{$_}->[VALUE] = undef for $self->ls_accessors; return 1; } =head2 $bool = $self->mk_verify; Checks if all values in the current object are in accordance with their own allow handler. Specifically useful to check if an empty initialised object has been filled with values satisfying their own allow criteria. =cut sub mk_verify { my $self = $_[0]; my $fail; for my $name ( $self->ls_accessors ) { unless( allow( $self->$name, $self->ls_allow( $name ) ) ) { my $val = defined $self->$name ? $self->$name : '<undef>'; __PACKAGE__->___error("'$name' ($val) is invalid"); $fail++; } } return if $fail; return 1; } =head2 $bool = $self->register_callback( sub { ... } ); This method allows you to register a callback, that is invoked every time an accessor is called. This allows you to munge input data, access external data stores, etc. You are free to return whatever you wish. On a C<set> call, the data is even stored in the object. Below is an example of the use of a callback. $object->some_method( "some_value" ); my $callback = sub { my $self = shift; # the object my $meth = shift; # "some_method" my $val = shift; # ["some_value"] # could be undef -- check 'exists'; # if scalar @$val is empty, it was a 'get' # your code here return $new_val; # the value you want to be set/returned } To access the values stored in the object, circumventing the callback structure, you should use the C<___get> and C<___set> methods documented further down. =cut sub register_callback { my $self = shift; my $sub = shift or return; ### use the memory address as key, it's not used EVER as an ### accessor --kane $self->___callback( $sub ); return 1; } =head2 $bool = $self->can( METHOD_NAME ) This method overrides C<UNIVERAL::can> in order to provide coderefs to accessors which are loaded on demand. It will behave just like C<UNIVERSAL::can> where it can -- returning a class method if it exists, or a closure pointing to a valid accessor of this particular object. You can use it as follows: $sub = $object->can('some_accessor'); # retrieve the coderef $sub->('foo'); # 'some_accessor' now set # to 'foo' for $object $foo = $sub->(); # retrieve the contents # of 'some_accessor' See the C<SYNOPSIS> for more examples. =cut ### custom 'can' as UNIVERSAL::can ignores autoload sub can { my($self, $method) = @_; ### it's one of our regular methods if( $self->UNIVERSAL::can($method) ) { __PACKAGE__->___debug( "Can '$method' -- provided by package" ); return $self->UNIVERSAL::can($method); } ### it's an accessor we provide; if( UNIVERSAL::isa( $self, 'HASH' ) and exists $self->{$method} ) { __PACKAGE__->___debug( "Can '$method' -- provided by object" ); return sub { $self->$method(@_); } } ### we don't support it __PACKAGE__->___debug( "Cannot '$method'" ); return; } ### don't autoload this sub DESTROY { 1 }; ### use autoload so we can have per-object accessors, ### not per class, as that is incorrect sub AUTOLOAD { my $self = shift; my($method) = ($AUTOLOAD =~ /([^:']+$)/); my $val = $self->___autoload( $method, @_ ) or return; return $val->[0]; } sub ___autoload { my $self = shift; my $method = shift; my $assign = scalar @_; # is this an assignment? ### a method on our object if( UNIVERSAL::isa( $self, 'HASH' ) ) { if ( not exists $self->{$method} ) { __PACKAGE__->___error("No such accessor '$method'", 1); return; } ### a method on something else, die with a descriptive error; } else { local $FATAL = 1; __PACKAGE__->___error( "You called '$AUTOLOAD' on '$self' which was interpreted by ". __PACKAGE__ . " as an object call. Did you mean to include ". "'$method' from somewhere else?", 1 ); } ### is this is an alias, redispatch to the original method if( my $original = $self->{ $method }->[ALIAS] ) { return $self->___autoload( $original, @_ ); } ### assign? my $val = $assign ? shift(@_) : $self->___get( $method ); if( $assign ) { ### any binding? if( $_[0] ) { if( ref $_[0] and UNIVERSAL::isa( $_[0], 'SCALAR' ) ) { ### tie the reference, so we get an object and ### we can use it's going out of scope to restore ### the old value my $cur = $self->{$method}->[VALUE]; tie ${$_[0]}, __PACKAGE__ . '::TIE', sub { $self->$method( $cur ) }; ${$_[0]} = $val; } else { __PACKAGE__->___error( "Can not bind '$method' to anything but a SCALAR", 1 ); } } ### need to check the value? if( defined $self->{$method}->[ALLOW] ) { ### double assignment due to 'used only once' warnings local $Params::Check::VERBOSE = 0; local $Params::Check::VERBOSE = 0; allow( $val, $self->{$method}->[ALLOW] ) or ( __PACKAGE__->___error( "'$val' is an invalid value for '$method'", 1), return ); } } ### callbacks? if( my $sub = $self->___callback ) { $val = eval { $sub->( $self, $method, ($assign ? [$val] : []) ) }; ### register the error $self->___error( $@, 1 ), return if $@; } ### now we can actually assign it if( $assign ) { $self->___set( $method, $val ) or return; } return [$val]; } =head2 $val = $self->___get( METHOD_NAME ); Method to directly access the value of the given accessor in the object. It circumvents all calls to allow checks, callbacks, etc. Use only if you C<Know What You Are Doing>! General usage for this functionality would be in your own custom callbacks. =cut ### XXX O::A::lvalue is mirroring this behaviour! if this ### changes, lvalue's autoload must be changed as well sub ___get { my $self = shift; my $method = shift or return; return $self->{$method}->[VALUE]; } =head2 $bool = $self->___set( METHOD_NAME => VALUE ); Method to directly set the value of the given accessor in the object. It circumvents all calls to allow checks, callbacks, etc. Use only if you C<Know What You Are Doing>! General usage for this functionality would be in your own custom callbacks. =cut sub ___set { my $self = shift; my $method = shift or return; ### you didn't give us a value to set! @_ or return; my $val = shift; ### if there's more arguments than $self, then ### replace the method called by the accessor. ### XXX implement rw vs ro accessors! $self->{$method}->[VALUE] = $val; return 1; } =head2 $bool = $self->___alias( ALIAS => METHOD ); Method to directly alias one accessor to another for this object. It circumvents all sanity checks, etc. Use only if you C<Know What You Are Doing>! =cut sub ___alias { my $self = shift; my $alias = shift or return; my $method = shift or return; $self->{ $alias }->[ALIAS] = $method; return 1; } sub ___debug { return unless $DEBUG; my $self = shift; my $msg = shift; my $lvl = shift || 0; local $Carp::CarpLevel += 1; carp($msg); } sub ___error { my $self = shift; my $msg = shift; my $lvl = shift || 0; local $Carp::CarpLevel += ($lvl + 1); $FATAL ? croak($msg) : carp($msg); } ### objects might be overloaded.. if so, we can't trust what "$self" ### will return, which might get *really* painful.. so check for that ### and get their unoverloaded stringval if needed. sub ___callback { my $self = shift; my $sub = shift; my $mem = overload::Overloaded( $self ) ? overload::StrVal( $self ) : "$self"; $self->{$mem} = $sub if $sub; return $self->{$mem}; } =head1 LVALUE ACCESSORS C<Object::Accessor> supports C<lvalue> attributes as well. To enable these, you should create your objects in the designated namespace, C<Object::Accessor::Lvalue>. For example: my $obj = Object::Accessor::Lvalue->new('foo'); $obj->foo += 1; print $obj->foo; will actually print C<1> and work as expected. Since this is an optional feature, that's not desirable in all cases, we require you to explicitly use the C<Object::Accessor::Lvalue> class. Doing the same on the standard C<Object>>Accessor> class would generate the following code & errors: my $obj = Object::Accessor->new('foo'); $obj->foo += 1; Can't modify non-lvalue subroutine call Note that C<lvalue> support on C<AUTOLOAD> routines is a C<perl 5.8.x> feature. See perldoc L<perl58delta> for details. =head2 CAVEATS =over 4 =item * Allow handlers Due to the nature of C<lvalue subs>, we never get access to the value you are assigning, so we can not check it against your allow handler. Allow handlers are therefor unsupported under C<lvalue> conditions. See C<perldoc perlsub> for details. =item * Callbacks Due to the nature of C<lvalue subs>, we never get access to the value you are assigning, so we can not check provide this value to your callback. Furthermore, we can not distinguish between a C<get> and a C<set> call. Callbacks are therefor unsupported under C<lvalue> conditions. See C<perldoc perlsub> for details. =cut { package Object::Accessor::Lvalue; use base 'Object::Accessor'; use strict; use vars qw[$AUTOLOAD]; ### constants needed to access values from the objects *VALUE = *Object::Accessor::VALUE; *ALLOW = *Object::Accessor::ALLOW; ### largely copied from O::A::Autoload sub AUTOLOAD : lvalue { my $self = shift; my($method) = ($AUTOLOAD =~ /([^:']+$)/); $self->___autoload( $method, @_ ) or return; ### *dont* add return to it, or it won't be stored ### see perldoc perlsub on lvalue subs ### XXX can't use $self->___get( ... ), as we MUST have ### the container that's used for the lvalue assign as ### the last statement... :( $self->{$method}->[ VALUE() ]; } sub mk_accessors { my $self = shift; my $is_hash = UNIVERSAL::isa( $_[0], 'HASH' ); $self->___error( "Allow handlers are not supported for '". __PACKAGE__ ."' objects" ) if $is_hash; return $self->SUPER::mk_accessors( @_ ); } sub register_callback { my $self = shift; $self->___error( "Callbacks are not supported for '". __PACKAGE__ ."' objects" ); return; } } ### standard tie class for bound attributes { package Object::Accessor::TIE; use Tie::Scalar; use Data::Dumper; use base 'Tie::StdScalar'; my %local = (); sub TIESCALAR { my $class = shift; my $sub = shift; my $ref = undef; my $obj = bless \$ref, $class; ### store the restore sub $local{ $obj } = $sub; return $obj; } sub DESTROY { my $tied = shift; my $sub = delete $local{ $tied }; ### run the restore sub to set the old value back return $sub->(); } } =back =head1 GLOBAL VARIABLES =head2 $Object::Accessor::FATAL Set this variable to true to make all attempted access to non-existent accessors be fatal. This defaults to C<false>. =head2 $Object::Accessor::DEBUG Set this variable to enable debugging output. This defaults to C<false>. =head1 TODO =head2 Create read-only accessors Currently all accessors are read/write for everyone. Perhaps a future release should make it possible to have read-only accessors as well. =head1 CAVEATS If you use codereferences for your allow handlers, you will not be able to freeze the data structures using C<Storable>. Due to a bug in storable (until at least version 2.15), C<qr//> compiled regexes also don't de-serialize properly. Although this bug has been reported, you should be aware of this issue when serializing your objects. You can track the bug here: http://rt.cpan.org/Ticket/Display.html?id=1827 =head1 BUG REPORTS Please report bugs or other issues to E<lt>bug-object-accessor@rt.cpan.orgE<gt>. =head1 AUTHOR This module by Jos Boumans E<lt>kane@cpan.orgE<gt>. =head1 COPYRIGHT This library is free software; you may redistribute and/or modify it under the same terms as Perl itself. =cut 1;
efortuna/AndroidSDKClone
ndk_experimental/prebuilt/linux-x86_64/lib/perl5/5.16.2/Object/Accessor.pm
Perl
apache-2.0
23,172
package HTTP::Daemon; use strict; use vars qw($VERSION @ISA $PROTO $DEBUG); $VERSION = "5.810"; use IO::Socket qw(AF_INET INADDR_ANY inet_ntoa); @ISA=qw(IO::Socket::INET); $PROTO = "HTTP/1.1"; sub new { my($class, %args) = @_; $args{Listen} ||= 5; $args{Proto} ||= 'tcp'; return $class->SUPER::new(%args); } sub accept { my $self = shift; my $pkg = shift || "HTTP::Daemon::ClientConn"; my ($sock, $peer) = $self->SUPER::accept($pkg); if ($sock) { ${*$sock}{'httpd_daemon'} = $self; return wantarray ? ($sock, $peer) : $sock; } else { return; } } sub url { my $self = shift; my $url = $self->_default_scheme . "://"; my $addr = $self->sockaddr; if (!$addr || $addr eq INADDR_ANY) { require Sys::Hostname; $url .= lc Sys::Hostname::hostname(); } else { $url .= gethostbyaddr($addr, AF_INET) || inet_ntoa($addr); } my $port = $self->sockport; $url .= ":$port" if $port != $self->_default_port; $url .= "/"; $url; } sub _default_port { 80; } sub _default_scheme { "http"; } sub product_tokens { "libwww-perl-daemon/$HTTP::Daemon::VERSION"; } package HTTP::Daemon::ClientConn; use vars qw(@ISA $DEBUG); use IO::Socket (); @ISA=qw(IO::Socket::INET); *DEBUG = \$HTTP::Daemon::DEBUG; use HTTP::Request (); use HTTP::Response (); use HTTP::Status; use HTTP::Date qw(time2str); use LWP::MediaTypes qw(guess_media_type); use Carp (); my $CRLF = "\015\012"; # "\r\n" is not portable my $HTTP_1_0 = _http_version("HTTP/1.0"); my $HTTP_1_1 = _http_version("HTTP/1.1"); sub get_request { my($self, $only_headers) = @_; if (${*$self}{'httpd_nomore'}) { $self->reason("No more requests from this connection"); return; } $self->reason(""); my $buf = ${*$self}{'httpd_rbuf'}; $buf = "" unless defined $buf; my $timeout = $ {*$self}{'io_socket_timeout'}; my $fdset = ""; vec($fdset, $self->fileno, 1) = 1; local($_); READ_HEADER: while (1) { # loop until we have the whole header in $buf $buf =~ s/^(?:\015?\012)+//; # ignore leading blank lines if ($buf =~ /\012/) { # potential, has at least one line if ($buf =~ /^\w+[^\012]+HTTP\/\d+\.\d+\015?\012/) { if ($buf =~ /\015?\012\015?\012/) { last READ_HEADER; # we have it } elsif (length($buf) > 16*1024) { $self->send_error(413); # REQUEST_ENTITY_TOO_LARGE $self->reason("Very long header"); return; } } else { last READ_HEADER; # HTTP/0.9 client } } elsif (length($buf) > 16*1024) { $self->send_error(414); # REQUEST_URI_TOO_LARGE $self->reason("Very long first line"); return; } print STDERR "Need more data for complete header\n" if $DEBUG; return unless $self->_need_more($buf, $timeout, $fdset); } if ($buf !~ s/^(\S+)[ \t]+(\S+)(?:[ \t]+(HTTP\/\d+\.\d+))?[^\012]*\012//) { ${*$self}{'httpd_client_proto'} = _http_version("HTTP/1.0"); $self->send_error(400); # BAD_REQUEST $self->reason("Bad request line: $buf"); return; } my $method = $1; my $uri = $2; my $proto = $3 || "HTTP/0.9"; $uri = "http://$uri" if $method eq "CONNECT"; $uri = $HTTP::URI_CLASS->new($uri, $self->daemon->url); my $r = HTTP::Request->new($method, $uri); $r->protocol($proto); ${*$self}{'httpd_client_proto'} = $proto = _http_version($proto); ${*$self}{'httpd_head'} = ($method eq "HEAD"); if ($proto >= $HTTP_1_0) { # we expect to find some headers my($key, $val); HEADER: while ($buf =~ s/^([^\012]*)\012//) { $_ = $1; s/\015$//; if (/^([^:\s]+)\s*:\s*(.*)/) { $r->push_header($key, $val) if $key; ($key, $val) = ($1, $2); } elsif (/^\s+(.*)/) { $val .= " $1"; } else { last HEADER; } } $r->push_header($key, $val) if $key; } my $conn = $r->header('Connection'); if ($proto >= $HTTP_1_1) { ${*$self}{'httpd_nomore'}++ if $conn && lc($conn) =~ /\bclose\b/; } else { ${*$self}{'httpd_nomore'}++ unless $conn && lc($conn) =~ /\bkeep-alive\b/; } if ($only_headers) { ${*$self}{'httpd_rbuf'} = $buf; return $r; } # Find out how much content to read my $te = $r->header('Transfer-Encoding'); my $ct = $r->header('Content-Type'); my $len = $r->header('Content-Length'); # Act on the Expect header, if it's there for my $e ( $r->header('Expect') ) { if( lc($e) eq '100-continue' ) { $self->send_status_line(100); } else { $self->send_error(417); $self->reason("Unsupported Expect header value"); return; } } if ($te && lc($te) eq 'chunked') { # Handle chunked transfer encoding my $body = ""; CHUNK: while (1) { print STDERR "Chunked\n" if $DEBUG; if ($buf =~ s/^([^\012]*)\012//) { my $chunk_head = $1; unless ($chunk_head =~ /^([0-9A-Fa-f]+)/) { $self->send_error(400); $self->reason("Bad chunk header $chunk_head"); return; } my $size = hex($1); last CHUNK if $size == 0; my $missing = $size - length($buf) + 2; # 2=CRLF at chunk end # must read until we have a complete chunk while ($missing > 0) { print STDERR "Need $missing more bytes\n" if $DEBUG; my $n = $self->_need_more($buf, $timeout, $fdset); return unless $n; $missing -= $n; } $body .= substr($buf, 0, $size); substr($buf, 0, $size+2) = ''; } else { # need more data in order to have a complete chunk header return unless $self->_need_more($buf, $timeout, $fdset); } } $r->content($body); # pretend it was a normal entity body $r->remove_header('Transfer-Encoding'); $r->header('Content-Length', length($body)); my($key, $val); FOOTER: while (1) { if ($buf !~ /\012/) { # need at least one line to look at return unless $self->_need_more($buf, $timeout, $fdset); } else { $buf =~ s/^([^\012]*)\012//; $_ = $1; s/\015$//; if (/^([\w\-]+)\s*:\s*(.*)/) { $r->push_header($key, $val) if $key; ($key, $val) = ($1, $2); } elsif (/^\s+(.*)/) { $val .= " $1"; } elsif (!length) { last FOOTER; } else { $self->reason("Bad footer syntax"); return; } } } $r->push_header($key, $val) if $key; } elsif ($te) { $self->send_error(501); # Unknown transfer encoding $self->reason("Unknown transfer encoding '$te'"); return; } elsif ($ct && lc($ct) =~ m/^multipart\/\w+\s*;.*boundary\s*=\s*(\w+)/) { # Handle multipart content type my $boundary = "$CRLF--$1--$CRLF"; my $index; while (1) { $index = index($buf, $boundary); last if $index >= 0; # end marker not yet found return unless $self->_need_more($buf, $timeout, $fdset); } $index += length($boundary); $r->content(substr($buf, 0, $index)); substr($buf, 0, $index) = ''; } elsif ($len) { # Plain body specified by "Content-Length" my $missing = $len - length($buf); while ($missing > 0) { print "Need $missing more bytes of content\n" if $DEBUG; my $n = $self->_need_more($buf, $timeout, $fdset); return unless $n; $missing -= $n; } if (length($buf) > $len) { $r->content(substr($buf,0,$len)); substr($buf, 0, $len) = ''; } else { $r->content($buf); $buf=''; } } ${*$self}{'httpd_rbuf'} = $buf; $r; } sub _need_more { my $self = shift; #my($buf,$timeout,$fdset) = @_; if ($_[1]) { my($timeout, $fdset) = @_[1,2]; print STDERR "select(,,,$timeout)\n" if $DEBUG; my $n = select($fdset,undef,undef,$timeout); unless ($n) { $self->reason(defined($n) ? "Timeout" : "select: $!"); return; } } print STDERR "sysread()\n" if $DEBUG; my $n = sysread($self, $_[0], 2048, length($_[0])); $self->reason(defined($n) ? "Client closed" : "sysread: $!") unless $n; $n; } sub read_buffer { my $self = shift; my $old = ${*$self}{'httpd_rbuf'}; if (@_) { ${*$self}{'httpd_rbuf'} = shift; } $old; } sub reason { my $self = shift; my $old = ${*$self}{'httpd_reason'}; if (@_) { ${*$self}{'httpd_reason'} = shift; } $old; } sub proto_ge { my $self = shift; ${*$self}{'httpd_client_proto'} >= _http_version(shift); } sub _http_version { local($_) = shift; return 0 unless m,^(?:HTTP/)?(\d+)\.(\d+)$,i; $1 * 1000 + $2; } sub antique_client { my $self = shift; ${*$self}{'httpd_client_proto'} < $HTTP_1_0; } sub force_last_request { my $self = shift; ${*$self}{'httpd_nomore'}++; } sub head_request { my $self = shift; ${*$self}{'httpd_head'}; } sub send_status_line { my($self, $status, $message, $proto) = @_; return if $self->antique_client; $status ||= RC_OK; $message ||= status_message($status) || ""; $proto ||= $HTTP::Daemon::PROTO || "HTTP/1.1"; print $self "$proto $status $message$CRLF"; } sub send_crlf { my $self = shift; print $self $CRLF; } sub send_basic_header { my $self = shift; return if $self->antique_client; $self->send_status_line(@_); print $self "Date: ", time2str(time), $CRLF; my $product = $self->daemon->product_tokens; print $self "Server: $product$CRLF" if $product; } sub send_response { my $self = shift; my $res = shift; if (!ref $res) { $res ||= RC_OK; $res = HTTP::Response->new($res, @_); } my $content = $res->content; my $chunked; unless ($self->antique_client) { my $code = $res->code; $self->send_basic_header($code, $res->message, $res->protocol); if ($code =~ /^(1\d\d|[23]04)$/) { # make sure content is empty $res->remove_header("Content-Length"); $content = ""; } elsif ($res->request && $res->request->method eq "HEAD") { # probably OK } elsif (ref($content) eq "CODE") { if ($self->proto_ge("HTTP/1.1")) { $res->push_header("Transfer-Encoding" => "chunked"); $chunked++; } else { $self->force_last_request; } } elsif (length($content)) { $res->header("Content-Length" => length($content)); } else { $self->force_last_request; $res->header('connection','close'); } print $self $res->headers_as_string($CRLF); print $self $CRLF; # separates headers and content } if ($self->head_request) { # no content } elsif (ref($content) eq "CODE") { while (1) { my $chunk = &$content(); last unless defined($chunk) && length($chunk); if ($chunked) { printf $self "%x%s%s%s", length($chunk), $CRLF, $chunk, $CRLF; } else { print $self $chunk; } } print $self "0$CRLF$CRLF" if $chunked; # no trailers either } elsif (length $content) { print $self $content; } } sub send_redirect { my($self, $loc, $status, $content) = @_; $status ||= RC_MOVED_PERMANENTLY; Carp::croak("Status '$status' is not redirect") unless is_redirect($status); $self->send_basic_header($status); my $base = $self->daemon->url; $loc = $HTTP::URI_CLASS->new($loc, $base) unless ref($loc); $loc = $loc->abs($base); print $self "Location: $loc$CRLF"; if ($content) { my $ct = $content =~ /^\s*</ ? "text/html" : "text/plain"; print $self "Content-Type: $ct$CRLF"; } print $self $CRLF; print $self $content if $content && !$self->head_request; $self->force_last_request; # no use keeping the connection open } sub send_error { my($self, $status, $error) = @_; $status ||= RC_BAD_REQUEST; Carp::croak("Status '$status' is not an error") unless is_error($status); my $mess = status_message($status); $error ||= ""; $mess = <<EOT; <title>$status $mess</title> <h1>$status $mess</h1> $error EOT unless ($self->antique_client) { $self->send_basic_header($status); print $self "Content-Type: text/html$CRLF"; print $self "Content-Length: " . length($mess) . $CRLF; print $self $CRLF; } print $self $mess unless $self->head_request; $status; } sub send_file_response { my($self, $file) = @_; if (-d $file) { $self->send_dir($file); } elsif (-f _) { # plain file local(*F); sysopen(F, $file, 0) or return $self->send_error(RC_FORBIDDEN); binmode(F); my($ct,$ce) = guess_media_type($file); my($size,$mtime) = (stat _)[7,9]; unless ($self->antique_client) { $self->send_basic_header; print $self "Content-Type: $ct$CRLF"; print $self "Content-Encoding: $ce$CRLF" if $ce; print $self "Content-Length: $size$CRLF" if $size; print $self "Last-Modified: ", time2str($mtime), "$CRLF" if $mtime; print $self $CRLF; } $self->send_file(\*F) unless $self->head_request; return RC_OK; } else { $self->send_error(RC_NOT_FOUND); } } sub send_dir { my($self, $dir) = @_; $self->send_error(RC_NOT_FOUND) unless -d $dir; $self->send_error(RC_NOT_IMPLEMENTED); } sub send_file { my($self, $file) = @_; my $opened = 0; local(*FILE); if (!ref($file)) { open(FILE, $file) || return undef; binmode(FILE); $file = \*FILE; $opened++; } my $cnt = 0; my $buf = ""; my $n; while ($n = sysread($file, $buf, 8*1024)) { last if !$n; $cnt += $n; print $self $buf; } close($file) if $opened; $cnt; } sub daemon { my $self = shift; ${*$self}{'httpd_daemon'}; } 1; __END__ =head1 NAME HTTP::Daemon - a simple http server class =head1 SYNOPSIS use HTTP::Daemon; use HTTP::Status; my $d = HTTP::Daemon->new || die; print "Please contact me at: <URL:", $d->url, ">\n"; while (my $c = $d->accept) { while (my $r = $c->get_request) { if ($r->method eq 'GET' and $r->url->path eq "/xyzzy") { # remember, this is *not* recommended practice :-) $c->send_file_response("/etc/passwd"); } else { $c->send_error(RC_FORBIDDEN) } } $c->close; undef($c); } =head1 DESCRIPTION Instances of the C<HTTP::Daemon> class are HTTP/1.1 servers that listen on a socket for incoming requests. The C<HTTP::Daemon> is a subclass of C<IO::Socket::INET>, so you can perform socket operations directly on it too. The accept() method will return when a connection from a client is available. The returned value will be an C<HTTP::Daemon::ClientConn> object which is another C<IO::Socket::INET> subclass. Calling the get_request() method on this object will read data from the client and return an C<HTTP::Request> object. The ClientConn object also provide methods to send back various responses. This HTTP daemon does not fork(2) for you. Your application, i.e. the user of the C<HTTP::Daemon> is responsible for forking if that is desirable. Also note that the user is responsible for generating responses that conform to the HTTP/1.1 protocol. The following methods of C<HTTP::Daemon> are new (or enhanced) relative to the C<IO::Socket::INET> base class: =over 4 =item $d = HTTP::Daemon->new =item $d = HTTP::Daemon->new( %opts ) The constructor method takes the same arguments as the C<IO::Socket::INET> constructor, but unlike its base class it can also be called without any arguments. The daemon will then set up a listen queue of 5 connections and allocate some random port number. A server that wants to bind to some specific address on the standard HTTP port will be constructed like this: $d = HTTP::Daemon->new( LocalAddr => 'www.thisplace.com', LocalPort => 80, ); See L<IO::Socket::INET> for a description of other arguments that can be used configure the daemon during construction. =item $c = $d->accept =item $c = $d->accept( $pkg ) =item ($c, $peer_addr) = $d->accept This method works the same the one provided by the base class, but it returns an C<HTTP::Daemon::ClientConn> reference by default. If a package name is provided as argument, then the returned object will be blessed into the given class. It is probably a good idea to make that class a subclass of C<HTTP::Daemon::ClientConn>. The accept method will return C<undef> if timeouts have been enabled and no connection is made within the given time. The timeout() method is described in L<IO::Socket>. In list context both the client object and the peer address will be returned; see the description of the accept method L<IO::Socket> for details. =item $d->url Returns a URL string that can be used to access the server root. =item $d->product_tokens Returns the name that this server will use to identify itself. This is the string that is sent with the C<Server> response header. The main reason to have this method is that subclasses can override it if they want to use another product name. The default is the string "libwww-perl-daemon/#.##" where "#.##" is replaced with the version number of this module. =back The C<HTTP::Daemon::ClientConn> is a C<IO::Socket::INET> subclass. Instances of this class are returned by the accept() method of C<HTTP::Daemon>. The following methods are provided: =over 4 =item $c->get_request =item $c->get_request( $headers_only ) This method read data from the client and turns it into an C<HTTP::Request> object which is returned. It returns C<undef> if reading fails. If it fails, then the C<HTTP::Daemon::ClientConn> object ($c) should be discarded, and you should not try call this method again on it. The $c->reason method might give you some information about why $c->get_request failed. The get_request() method will normally not return until the whole request has been received from the client. This might not be what you want if the request is an upload of a large file (and with chunked transfer encoding HTTP can even support infinite request messages - uploading live audio for instance). If you pass a TRUE value as the $headers_only argument, then get_request() will return immediately after parsing the request headers and you are responsible for reading the rest of the request content. If you are going to call $c->get_request again on the same connection you better read the correct number of bytes. =item $c->read_buffer =item $c->read_buffer( $new_value ) Bytes read by $c->get_request, but not used are placed in the I<read buffer>. The next time $c->get_request is called it will consume the bytes in this buffer before reading more data from the network connection itself. The read buffer is invalid after $c->get_request has failed. If you handle the reading of the request content yourself you need to empty this buffer before you read more and you need to place unconsumed bytes here. You also need this buffer if you implement services like I<101 Switching Protocols>. This method always return the old buffer content and can optionally replace the buffer content if you pass it an argument. =item $c->reason When $c->get_request returns C<undef> you can obtain a short string describing why it happened by calling $c->reason. =item $c->proto_ge( $proto ) Return TRUE if the client announced a protocol with version number greater or equal to the given argument. The $proto argument can be a string like "HTTP/1.1" or just "1.1". =item $c->antique_client Return TRUE if the client speaks the HTTP/0.9 protocol. No status code and no headers should be returned to such a client. This should be the same as !$c->proto_ge("HTTP/1.0"). =item $c->head_request Return TRUE if the last request was a C<HEAD> request. No content body must be generated for these requests. =item $c->force_last_request Make sure that $c->get_request will not try to read more requests off this connection. If you generate a response that is not self delimiting, then you should signal this fact by calling this method. This attribute is turned on automatically if the client announces protocol HTTP/1.0 or worse and does not include a "Connection: Keep-Alive" header. It is also turned on automatically when HTTP/1.1 or better clients send the "Connection: close" request header. =item $c->send_status_line =item $c->send_status_line( $code ) =item $c->send_status_line( $code, $mess ) =item $c->send_status_line( $code, $mess, $proto ) Send the status line back to the client. If $code is omitted 200 is assumed. If $mess is omitted, then a message corresponding to $code is inserted. If $proto is missing the content of the $HTTP::Daemon::PROTO variable is used. =item $c->send_crlf Send the CRLF sequence to the client. =item $c->send_basic_header =item $c->send_basic_header( $code ) =item $c->send_basic_header( $code, $mess ) =item $c->send_basic_header( $code, $mess, $proto ) Send the status line and the "Date:" and "Server:" headers back to the client. This header is assumed to be continued and does not end with an empty CRLF line. See the description of send_status_line() for the description of the accepted arguments. =item $c->send_response( $res ) Write a C<HTTP::Response> object to the client as a response. We try hard to make sure that the response is self delimiting so that the connection can stay persistent for further request/response exchanges. The content attribute of the C<HTTP::Response> object can be a normal string or a subroutine reference. If it is a subroutine, then whatever this callback routine returns is written back to the client as the response content. The routine will be called until it return an undefined or empty value. If the client is HTTP/1.1 aware then we will use chunked transfer encoding for the response. =item $c->send_redirect( $loc ) =item $c->send_redirect( $loc, $code ) =item $c->send_redirect( $loc, $code, $entity_body ) Send a redirect response back to the client. The location ($loc) can be an absolute or relative URL. The $code must be one the redirect status codes, and defaults to "301 Moved Permanently" =item $c->send_error =item $c->send_error( $code ) =item $c->send_error( $code, $error_message ) Send an error response back to the client. If the $code is missing a "Bad Request" error is reported. The $error_message is a string that is incorporated in the body of the HTML entity body. =item $c->send_file_response( $filename ) Send back a response with the specified $filename as content. If the file is a directory we try to generate an HTML index of it. =item $c->send_file( $filename ) =item $c->send_file( $fd ) Copy the file to the client. The file can be a string (which will be interpreted as a filename) or a reference to an C<IO::Handle> or glob. =item $c->daemon Return a reference to the corresponding C<HTTP::Daemon> object. =back =head1 SEE ALSO RFC 2616 L<IO::Socket::INET>, L<IO::Socket> =head1 COPYRIGHT Copyright 1996-2003, Gisle Aas This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
leighpauls/k2cro4
third_party/cygwin/lib/perl5/vendor_perl/5.10/HTTP/Daemon.pm
Perl
bsd-3-clause
22,843
package OtherTypes; no warnings; our $foo = 23; our @foo = "bar"; our %foo = (mouse => "trap"); open foo, "<", $0; format foo = foo . BEGIN { $main::pvio = *foo{IO}; $main::pvfm = *foo{FORMAT}; } sub foo { 1 } use autodie 'foo'; 1;
Lh4cKg/sl4a
perl/src/lib/autodie/t/lib/OtherTypes.pm
Perl
apache-2.0
246
#!/usr/bin/env perl # Copyright 2009 The Go Authors. All rights reserved. # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. # # Generate system call table for OpenBSD from master list # (for example, /usr/src/sys/kern/syscalls.master). use strict; if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { print STDERR "GOARCH or GOOS not defined in environment\n"; exit 1; } my $command = "mksysnum_netbsd.pl " . join(' ', @ARGV); print <<EOF; // $command // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT // +build $ENV{'GOARCH'},$ENV{'GOOS'} package unix const ( EOF my $line = ''; while(<>){ if($line =~ /^(.*)\\$/) { # Handle continuation $line = $1; $_ =~ s/^\s+//; $line .= $_; } else { # New line $line = $_; } next if $line =~ /\\$/; if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) { my $num = $1; my $proto = $6; my $compat = $8; my $name = "$7_$9"; $name = "$7_$11" if $11 ne ''; $name =~ y/a-z/A-Z/; if($compat eq '' || $compat eq '30' || $compat eq '50') { print " $name = $num; // $proto\n"; } } } print <<EOF; ) EOF
muzining/net
x/sys/unix/mksysnum_netbsd.pl
Perl
bsd-3-clause
1,195
combination(0, _, []). combination(N, [H|T], [H|Comb]) :- M is (N - 1), combination(M, T, Comb). combination(N, [_|T], Comb) :- N > 0, combination(N, T, Comb).
dvberkel/99-prolog-problems
Prolog-Lists/26.pl
Perl
mit
160
#!/usr/bin/perl -w # # ***** BEGIN LICENSE BLOCK ***** # Zimbra Collaboration Suite Server # Copyright (C) 2005, 2007, 2009, 2010 Zimbra, Inc. # # The contents of this file are subject to the Zimbra Public License # Version 1.3 ("License"); you may not use this file except in # compliance with the License. You may obtain a copy of the License at # http://www.zimbra.com/license. # # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. # ***** END LICENSE BLOCK ***** # # # Simple SOAP test-harness for the AddMsg API # use Date::Parse; use Time::HiRes qw ( time ); use strict; use lib '.'; use LWP::UserAgent; use XmlElement; use XmlDoc; use Soap; my $userId; my $addr; my $show = ""; my $status; if (defined $ARGV[1] && $ARGV[1] ne "") { $userId = shift(@ARGV); $show = shift(@ARGV); if (defined $ARGV[0]) { $status = shift(@ARGV); } } else { print "USAGE: IMSetMyPres USERID SHOW [status]\n"; exit 1; } print "Status is $status\n"; my $ACCTNS = "urn:zimbraAccount"; my $MAILNS = "urn:zimbraIM"; my $url = "http://localhost:7070/service/soap/"; my $SOAP = $Soap::Soap12; my $d = new XmlDoc; $d->start('AuthRequest', $ACCTNS); $d->add('account', undef, { by => "name"}, $userId); $d->add('password', undef, undef, "test123"); $d->end(); my $authResponse = $SOAP->invoke($url, $d->root()); print "AuthResponse = ".$authResponse->to_string("pretty")."\n"; my $authToken = $authResponse->find_child('authToken')->content; print "authToken($authToken)\n"; my $sessionId = $authResponse->find_child('sessionId')->content; print "sessionId = $sessionId\n"; my $context = $SOAP->zimbraContext($authToken, $sessionId); my $contextStr = $context->to_string("pretty"); print("Context = $contextStr\n"); $d = new XmlDoc; $d->start('IMSetPresenceRequest', $MAILNS); if (!defined($status)) { $d->add('presence', $MAILNS, { "show" => $show} ); } else { $d->add('presence', $MAILNS, { "show" => $show, "status" => $status } ); } $d->end(); # print "\nOUTGOING XML:\n-------------\n"; my $out = $d->to_string("pretty")."\n"; $out =~ s/ns0\://g; print $out."\n"; my $response = $SOAP->invoke($url, $d->root(), $context); print "\nRESPONSE:\n--------------\n"; $out = $response->to_string("pretty")."\n"; $out =~ s/ns0\://g; print $out."\n";
nico01f/z-pec
ZimbraServer/src/perl/soap/imsetpres.pl
Perl
mit
2,378
use Win32::OLE 'in'; use Win32::OLE::Const 'Microsoft WMI Scripting '; my $ComputerName = "."; my $NameSpace = "root/cimv2"; my $Locator=Win32::OLE->new("WbemScripting.SWbemLocator"); my $WbemServices = $Locator->ConnectServer($ComputerName, $NameSpace); my $className = "Win32_Process"; #Alle qualifiers ophalen my $Class = $WbemServices->Get($className,wbemFlagUseAmendedQualifiers); #Vergelijk met ophalen van Instance #my $Instances=$Class->Instances_(wbemFlagUseAmendedQualifiers); #print $Instances->{Count},"instances \n"; #($Class)=(in $Instances); my $Methods = $Class->{Methods_}; printf "\n%s bevat %d methodes met volgende aanroep (en extra return-waarde):\n ", $Class->{Path_}->{Class},$Methods->{Count}; foreach my $Method (sort {uc($a->{Name}) cmp uc($b->{Name})} in $Methods) { printf "\n\n\n------Methode %s ---(%s)-------------------- " ,$Method->{Name}, $Method->{Qualifiers_}->{Count}; foreach $qual (in $Method->{Qualifiers_}){ printf "\n%s: %s\n",$qual->{name}, ref $qual->{value} eq "ARRAY" ? join " , ",@{$qual->{Value}} : $qual->{Value}; } }
VDBBjorn/Besturingssystemen-III
Labo/reeks4/Reeks4_37.pl
Perl
mit
1,151
package WWW::EFA::Request; use Moose; use HTTP::Request; use MooseX::Params::Validate; use Digest::SHA qw/sha256_hex/; with 'WWW::EFA::Roles::Printable'; # provides to_string =head1 NAME WWW::EFA::Request - A request which can be passed around, and built up =head1 VERSION Version 0.01 =cut our $VERSION = '0.01'; =head1 SYNOPSIS URI request extended with some useful methods use WWW::EFA::Location; my $location = WWW::EFA::Location->new(); ... =head1 ATTRIBUTES TODO: RCL 2012-01-22 Documentation =cut has 'arguments' => ( is => 'rw', isa => 'HashRef', required => 1, default => sub{ return { outputFormat => 'XML', coordOutputFormat => 'WGS84', }; }, ); has 'base_url' => ( is => 'ro', isa => 'Str', required => 1, ); has 'can_accept_poid' => ( is => 'ro', isa => 'Bool', required => 1, default => 1, ); has 'service' => ( is => 'ro', isa => 'Str', required => 1, ); =head1 METHODS =head2 url Returns $string Get the URL for the request. Concatenation of base_url and service after common_params are set. =cut sub url { my $self = shift; $self->set_common_params(); return $self->base_url . $self->service; } =head2 set_common_params Set common parameters for the request =cut sub set_common_params { my $self = shift; # These are common to all services $self->set_argument( 'locationServerActive' , 1 ); $self->set_argument( 'SpEncId' , '0' ); # Set service specific parameters my $service = $self->service; if( $service eq 'XSLT_TRIP_REQUEST2' ){ $self->set_argument( 'coordListOutputFormat' , 'STRING' ); $self->set_argument( 'calcNumberOfTrips' , '4' ); } } =head2 add_location( $suffix, $location ) Add a location to the request. e.g. $request->add_location( 'origin', $location ); $location is a L<WWW::EFA::Location> object =cut sub add_location { my $self = shift; my ( $suffix, $location ) = pos_validated_list( \@_, { isa => 'Str' }, { isa => 'WWW::EFA::Location' }, ); if( $location->id ){ $self->set_argument( 'type_' . $suffix, 'stop' ); $self->set_argument( 'name_' . $suffix, $location->id ); } elsif ( $self->can_accept_poid and $location->poi_id ){ $self->set_argument( 'type_' . $suffix, 'poiID' ); $self->set_argument( 'name_' . $suffix, $location->poi_id ); }elsif( $location->coordinates ){ $self->set_argument( 'type_' . $suffix, 'coord' ); $self->set_argument( 'name_' . $suffix, sprintf( "%.6f:%.6f:WGS84", $location->coordinates->longitude, $location->coordinates->latitude, ) ); }else{ die( "Incomplete Location\n" ); } } =head2 set_argument( $key, $value ) Set an argument for the request. e.g. $request->set_argument( 'inclMOT_0', 'on' ); =cut sub set_argument { my $self = shift; my ( $key, $value ) = pos_validated_list( \@_, { isa => 'Str' }, { isa => 'Str' }, ); $self->arguments->{ $key } = $value; } =head2 del_argument( $key ) Added an argument you didn't mean to? Remove it here! e.g. $request->del_argument( $key ); =cut sub del_argument { my $self = shift; my ( $key ) = validated_list( \@_, key => { isa => 'Str' }, ); delete( $self->arguments->{ $key } ); } =head2 digest Returns $string Generate a sha256_hex digest of this request. =cut sub digest { my $self = shift; my $string = $self->url . "\n"; my %arguments = %{ $self->{arguments} }; foreach( sort keys( %arguments ) ){ $string .= "$_=$arguments{$_}\n"; } return sha256_hex( $string ); } 1;
aydindemircioglu/putrama
WWW/EFA/Request.pm
Perl
mit
3,957
% ontology is a collection of facts. Converted to CNF form. fact([-canFly(p:penguin)]). fact([+canFly(x:canFly)]). factSorts(Ss) :- Ss = [ (bot -> penguin), (bot -> canary), (bot -> emu), (penguin -> bird), (canary -> bird), (emu -> bird), (bird -> canFly), (canFly -> canMove), (canMove -> top) ]. factSortsRep(Ss) :- Ss = [ (bot -> canary), (bot -> penguin), (penguin -> bird), (canary -> flyingBird), (flyingBird -> canFly), (flyingBird -> bird), (canFly -> canMove), (bird -> canMove), (canMove -> top) ]. % notrace,[diagnose,repair,util,reform,revise,utilRevise,ibis2ont].
BorisMitrovic/sorted-reformation
ibis2ont.pl
Perl
mit
611
#!/usr/bin/perl -w # # Comment # # Create a new comment on a JIRA issue. # # Author: Nathan Helenihi # package JiraLite::Command::Comment; use strict; use warnings; use base qw( CLI::Framework::Command ); use JiraLite::Config::Jira; use JiraLite::Lib::Credentials; use JIRA::Client::Automated; use Data::Dumper; sub run { # Validate and configure arguments my $num_args = $#ARGV + 1; if ($num_args != 2) { print usage_text(); exit; } my $issue_id = $ARGV[0]; my $comment = $ARGV[1]; # Instantiate JIRA client with credentials my $creds = new JiraLite::Lib::Credentials(); my ($user, $password) = $creds->getCredentials(); my $jira = JIRA::Client::Automated->new($JiraLite::Config::Jira::URL, $user, $password); # Create comment my $result; eval { $result = $jira->create_comment($issue_id, $comment); }; warn $@ if $@; print "\n"; if ($result) { print "Successfully created comment."; } else { print "Failed to create comment."; } print "\n\n"; } sub usage_text { qq{ Usage: $0 <com|comment> <TID> <comment> $0 comment $JiraLite::Config::Jira::PROJECT-000 "This is a comment" } } 1;
MyAllocator/jiralite
JiraLite/Command/Comment.pm
Perl
mit
1,224
package Horse; use strict; use warnings; use Moose; use namespace::autoclean; extends 'Animal'; =head1 NAME Horse - class for the Alpaca book =head1 VERSION Version 0.01 =cut our $VERSION = '0.01'; =head1 SYNOPSIS Horse class, subclasses animal =cut has 'color' => (is => 'rw', default => 'brown'); sub sound { 'neigh' } __PACKAGE__->meta->make_immutable; 1;
bewuethr/ctci
alpaca_book/chapter19/chapter19_ex01/lib/Horse.pm
Perl
mit
374
#!/usr/bin/perl use strict; use warnings; use IPC::Open3; use Symbol 'gensym'; use IO::Handle; use Test::More qw/ no_plan /; my $USDT_ARG_MAX = 32; if ($^O eq 'freebsd') { # FreeBSD currently only supports 5 arguments to USDT probes $USDT_ARG_MAX = 5; } my $arch; if (scalar @ARGV == 1) { $arch = $ARGV[0]; } my $user_t = ($^O eq 'darwin') ? 'user_addr_t' : 'uintptr_t'; run_tests('c', 'A'); run_tests('i', 1); sub run_tests { my ($type, $start_arg) = @_; for my $i (0..$USDT_ARG_MAX) { my ($t_status, $d_status, $output) = run_dtrace('type'.$type, $i.'arg', split(//, $type x $i)); is($t_status, 0, 'test exit status is 0'); is($d_status, 0, 'dtrace exit status is 0'); like($output, qr/type[ic]:\d+arg/, 'function and name match'); my $arg = $start_arg; for my $j (0..$i - 1) { like($output, qr/arg$j:'\Q$arg\E'/, "type '$type' arg $j is $arg"); if ($type eq 'i') { $arg++; } else { $arg = chr(ord($arg) + 1); } } } } # -------------------------------------------------------------------------- sub gen_d { my (@types) = @_; my $d = 'testlibusdt*:::{ '; my $i = 0; for my $type (@types) { if ($type eq 'i') { $d .= "printf(\"arg$i:'%i' \", args[$i]); "; } if ($type eq 'c') { $d .= "printf(\"arg$i:'%s' \", copyinstr(($user_t)args[$i])); "; } $i++; } $d .= '}'; return $d; } sub run_dtrace { my ($func, $name, @types) = @_; my $d = gen_d(@types); my @t_cmd; if (defined $arch) { @t_cmd = ("./test_usdt$arch", $func, $name, @types); } else { @t_cmd = ("./test_usdt", $func, $name, @types); } my ($d_wtr, $d_rdr, $d_err); my ($t_wtr, $t_rdr, $t_err); $d_err = gensym; $t_err = gensym; #diag(join(' ', @t_cmd)); my $t_pid = open3($t_wtr, $t_rdr, $t_err, @t_cmd); my $enabled = $t_rdr->getline; my @d_cmd = ('/usr/sbin/dtrace', '-p', $t_pid, '-n', $d); #diag(join(' ', @d_cmd)); my $d_pid = open3($d_wtr, $d_rdr, $d_err, @d_cmd); my $matched = $d_err->getline; # expect "matched 1 probe" $t_wtr->print("go\n"); $t_wtr->flush; waitpid( $t_pid, 0 ); my $t_status = $? >> 8; my ($header, $output) = ($d_rdr->getline, $d_rdr->getline); chomp $header; chomp $output; #diag("DTrace header: $header\n"); #diag("DTrace output: $output\n"); waitpid( $d_pid, 0 ); my $d_status = $? >> 8; while (!$d_err->eof) { my $error = $d_err->getline; chomp $error; #diag "DTrace error: $error"; } return ($t_status, $d_status, $output || ''); }
hejiheji001/HexoBlog
node_modules/hexo/node_modules/bunyan/node_modules/dtrace-provider/libusdt/test.pl
Perl
mit
2,906
use strict; use lib "../lib"; use lib "../../lib"; use Test::More "no_plan"; use Data::Dumper; use Eldhelm::Util::ExternalScript; use MIME::Base64 qw(encode_base64 decode_base64); my ($a1, $a2) = Eldhelm::Util::ExternalScript->encodeArgv([ { a => 5 }, { b => 10 }, { c => 15 } ], { a => 1, b => 2 }); ok($a1, "has some input"); ok($a2, "has some input"); diag("parse argv"); my ($pa1) = Eldhelm::Util::ExternalScript->parseArg($a1); is(ref($pa1), "ARRAY", "param"); diag("test argv"); my ($p1, $p2) = Eldhelm::Util::ExternalScript->argv($a1, $a2); note($p1); is(ref($p1), "ARRAY", "param 1"); is($p1->[1]{b}, 10); is($p1->[2]{c}, 15); note($p2); is(ref($p2), "HASH", "param 2"); is($p2->{a}, 1); is($p2->{b}, 2);
wastedabuser/eldhelm-platform
test/t/303_external_script.pl
Perl
mit
719
/* % NomicMUD: A MUD server written in Prolog % Maintainer: Douglas Miles % Dec 13, 2035 % % Bits and pieces: % % LogicMOO, Inform7, FROLOG, Guncho, PrologMUD and Marty's Prolog Adventure Prototype % % Copyright (C) 2004 Marty White under the GNU GPL % Sept 20, 1999 - Douglas Miles % July 10, 1996 - John Eikenberry % % Logicmoo Project changes: % % Main file. % */ :- use_module(library(logicmoo_common)). :- '$set_source_module'(mu). % :- ensure_loaded(adv_loader). % :- user:ensure_loaded(library(parser_sharing)). :- ensure_loaded(adv_debug). :- ensure_loaded(adv_help). :- ensure_loaded(adv_util). :- ensure_loaded(adv_io). :- ensure_loaded(adv_model). :- ensure_loaded(adv_percept). :- ensure_loaded(adv_inst). :- ensure_loaded(adv_edit). :- ensure_loaded(adv_behaviour_tree). %:- ensure_loaded(adv_axiom). :- ensure_loaded(adv_implies). %:- ensure_loaded(adv_abdemo). :- ensure_loaded(adv_examine). :- ensure_loaded(adv_action). :- ensure_loaded(adv_agent). :- ensure_loaded(adv_floyd). :- ensure_loaded(adv_physics). :- ensure_loaded(adv_plan). :- ensure_loaded(adv_functors). :- ensure_loaded(adv_eng2txt). :- ensure_loaded(adv_log2eng). :- ensure_loaded(adv_eng2cmd). %:- ensure_loaded(adv_lexicon). :- ensure_loaded(adv_quasiquote). :- ensure_loaded(adv_state). :- ensure_loaded(adv_portray). :- ensure_loaded(adv_data). :- ensure_loaded(adv_plugins).
TeamSPoon/logicmoo_workspace
packs_sys/logicmoo_agi/prolog/episodic_memory/adv_loader.pl
Perl
mit
1,381
# !!!!!!! DO NOT EDIT THIS FILE !!!!!!! # This file is machine-generated by lib/unicore/mktables from the Unicode # database, Version 12.1.0. Any changes made here will be lost! # !!!!!!! INTERNAL PERL USE ONLY !!!!!!! # This file is for internal use by core Perl only. The format and even the # name or existence of this file are subject to change without notice. Don't # use it directly. Use Unicode::UCD to access the Unicode character data # base. return <<'END'; V30 45 46 160 161 215 216 2432 2433 2674 2676 4171 4172 4174 4175 6400 6401 7418 7419 8208 8213 9676 9677 43636 43639 72255 72256 72261 72262 73458 73459 END
operepo/ope
client_tools/svc/rc/usr/share/perl5/core_perl/unicore/lib/InSC/Consona6.pl
Perl
mit
641
package Matrix; use strict; use warnings; use Exporter qw<import>; our @EXPORT_OK = qw<row column>; sub row { my ($input) = @_; return undef; } sub column { my ($input) = @_; return undef; } 1;
exercism/xperl5
exercises/practice/matrix/Matrix.pm
Perl
mit
205
#!/usr/bin/perl -w # # see usage() or run eDNS.pl with no command line # for usage information # use strict; use vars qw($myip $firewall $target $username $password $version); use vars qw($pass $url $sock @result $result $code $domain); use Getopt::Long; GetOptions('u=s' => \$username, 'p=s' => \$password, 'ip=s' => \$myip, 'd=s' => \$domain); usage() if !$username; usage() if !$password; # If you're behind a firewall or HTTP proxy, set this to 1. # If you're not sure, set it to 1; that's the safer setting anyway. # If you KNOW you're not behind a firewall or proxy, set to 0. $firewall = 0; # Originally written for hn.org by: # # (C)2000-2001 David E. Smith <dave@bureau42.com> and released to the # public under the terms of the GNU General Public License. # # With credits given to: # # Modified by Daniel Hagan <dhagan@colltech.com> on 4/2001 to use IO::Socket, # Syslog, and some error checking. Now logs all output to daemon facility. # # Other changes made/suggested by Aurelien Beaujean <aure@dagobah.eu.org> # Sorry, but I can't type the accent over the first "e" in Aurelien. # # It was then hacked up to work with Everydns.net by Dave Fortunato # <davidf@everydns.net> use MIME::Base64; use IO::Socket; if ($firewall && !$myip) { die "Error: IP required as command line argument when \$firewall is set to true."; } $target = "dyn.everydns.net"; $version = "0.1"; $pass = MIME::Base64::encode_base64("$username:$password"); if ($firewall == 1 or $myip) { $url = "/index.php?ver=$version&ip=$myip" if !$domain; $url = "/index.php?ver=$version&ip=$myip&domain=$domain" if $domain; } else { $url = "/index.php?ver=$version" if !$domain; $url = "/index.php?ver=$version&domain=$domain" if $domain; } $sock = new IO::Socket::INET( PeerAddr => "$target", PeerPort => 'http(80)' ); if (!$sock) { print "Connect failed\n\n"; exit(1); } $sock->autoflush(1); $sock->print("GET $url HTTP/1.0\r\n"); $sock->print("User-Agent: eDNS.pl $version\r\n"); $sock->print("Host: $target\r\n"); $sock->print("Authorization: Basic $pass\r\n\r\n"); @result = $sock->getlines(); undef $sock; #Close the socket $result = join '', @result; #print $result; #uncomment for debugging information $result =~ m/Exit Code: (\d+)/i; $code = $1; if ($code eq "0" and $myip) { print "Succeeded in setting domain to $myip.\n"; exit(0); } elsif ($code eq "0" and !$myip){ print "Succeeded in setting domain to current ip address\n"; exit(0); } else { print "Received Exit Code $code, probably failed.\n"; exit(1); } sub usage { print "Usage: eDNS.exe -u username -p password -ip IP_Address -d domain\n"; print "Or : eDNS.exe -u username -p password -d domain\n"; print "Or : eDNS.exe -u username -p password\n"; exit(1); }
yjpark/dotfiles
external/bin.linux/eDNS.pl
Perl
mit
2,772
package kb_vsearch::kb_vsearchClient; use JSON::RPC::Client; use POSIX; use strict; use Data::Dumper; use URI; use Bio::KBase::Exceptions; my $get_time = sub { time, 0 }; eval { require Time::HiRes; $get_time = sub { Time::HiRes::gettimeofday() }; }; use Bio::KBase::AuthToken; # Client version should match Impl version # This is a Semantic Version number, # http://semver.org our $VERSION = "0.1.0"; =head1 NAME kb_vsearch::kb_vsearchClient =head1 DESCRIPTION ** A KBase module: kb_vsearch ** ** This module contains 4 methods from VSEARCH: basic query/db search, clustering, chimera detection, and dereplication. ** ** Initially only basic query/db search will be implemented between read sets =cut sub new { my($class, $url, @args) = @_; my $self = { client => kb_vsearch::kb_vsearchClient::RpcClient->new, url => $url, headers => [], }; chomp($self->{hostname} = `hostname`); $self->{hostname} ||= 'unknown-host'; # # Set up for propagating KBRPC_TAG and KBRPC_METADATA environment variables through # to invoked services. If these values are not set, we create a new tag # and a metadata field with basic information about the invoking script. # if ($ENV{KBRPC_TAG}) { $self->{kbrpc_tag} = $ENV{KBRPC_TAG}; } else { my ($t, $us) = &$get_time(); $us = sprintf("%06d", $us); my $ts = strftime("%Y-%m-%dT%H:%M:%S.${us}Z", gmtime $t); $self->{kbrpc_tag} = "C:$0:$self->{hostname}:$$:$ts"; } push(@{$self->{headers}}, 'Kbrpc-Tag', $self->{kbrpc_tag}); if ($ENV{KBRPC_METADATA}) { $self->{kbrpc_metadata} = $ENV{KBRPC_METADATA}; push(@{$self->{headers}}, 'Kbrpc-Metadata', $self->{kbrpc_metadata}); } if ($ENV{KBRPC_ERROR_DEST}) { $self->{kbrpc_error_dest} = $ENV{KBRPC_ERROR_DEST}; push(@{$self->{headers}}, 'Kbrpc-Errordest', $self->{kbrpc_error_dest}); } # # This module requires authentication. # # We create an auth token, passing through the arguments that we were (hopefully) given. { my $token = Bio::KBase::AuthToken->new(@args); if (!$token->error_message) { $self->{token} = $token->token; $self->{client}->{token} = $token->token; } else { # # All methods in this module require authentication. In this case, if we # don't have a token, we can't continue. # die "Authentication failed: " . $token->error_message; } } my $ua = $self->{client}->ua; my $timeout = $ENV{CDMI_TIMEOUT} || (30 * 60); $ua->timeout($timeout); bless $self, $class; # $self->_validate_version(); return $self; } =head2 VSearch_BasicSearch $return = $obj->VSearch_BasicSearch($params) =over 4 =item Parameter and return types =begin html <pre> $params is a kb_vsearch.VSearch_BasicSearch_Params $return is a kb_vsearch.VSearch_BasicSearch_Output VSearch_BasicSearch_Params is a reference to a hash where the following keys are defined: workspace_name has a value which is a kb_vsearch.workspace_name input_one_sequence has a value which is a kb_vsearch.sequence input_one_name has a value which is a kb_vsearch.data_obj_name input_many_name has a value which is a kb_vsearch.data_obj_name output_filtered_name has a value which is a kb_vsearch.data_obj_name maxaccepts has a value which is an int maxrejects has a value which is an int wordlength has a value which is an int minwordmatches has a value which is an int ident_thresh has a value which is a float ident_mode has a value which is an int workspace_name is a string sequence is a string data_obj_name is a string VSearch_BasicSearch_Output is a reference to a hash where the following keys are defined: report_name has a value which is a kb_vsearch.data_obj_name report_ref has a value which is a kb_vsearch.data_obj_ref data_obj_ref is a string </pre> =end html =begin text $params is a kb_vsearch.VSearch_BasicSearch_Params $return is a kb_vsearch.VSearch_BasicSearch_Output VSearch_BasicSearch_Params is a reference to a hash where the following keys are defined: workspace_name has a value which is a kb_vsearch.workspace_name input_one_sequence has a value which is a kb_vsearch.sequence input_one_name has a value which is a kb_vsearch.data_obj_name input_many_name has a value which is a kb_vsearch.data_obj_name output_filtered_name has a value which is a kb_vsearch.data_obj_name maxaccepts has a value which is an int maxrejects has a value which is an int wordlength has a value which is an int minwordmatches has a value which is an int ident_thresh has a value which is a float ident_mode has a value which is an int workspace_name is a string sequence is a string data_obj_name is a string VSearch_BasicSearch_Output is a reference to a hash where the following keys are defined: report_name has a value which is a kb_vsearch.data_obj_name report_ref has a value which is a kb_vsearch.data_obj_ref data_obj_ref is a string =end text =item Description Method for BasicSearch of one sequence against many sequences ** ** overloading as follows: ** input_one_id: SingleEndLibrary, FeatureSet ** input_many_id: SingleEndLibrary, FeatureSet, Genome, GenomeSet ** output_id: SingleEndLibrary (if input_many is SELib), FeatureSet =back =cut sub VSearch_BasicSearch { my($self, @args) = @_; # Authentication: required if ((my $n = @args) != 1) { Bio::KBase::Exceptions::ArgumentValidationError->throw(error => "Invalid argument count for function VSearch_BasicSearch (received $n, expecting 1)"); } { my($params) = @args; my @_bad_arguments; (ref($params) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"params\" (value was \"$params\")"); if (@_bad_arguments) { my $msg = "Invalid arguments passed to VSearch_BasicSearch:\n" . join("", map { "\t$_\n" } @_bad_arguments); Bio::KBase::Exceptions::ArgumentValidationError->throw(error => $msg, method_name => 'VSearch_BasicSearch'); } } my $result = $self->{client}->call($self->{url}, $self->{headers}, { method => "kb_vsearch.VSearch_BasicSearch", params => \@args, }); if ($result) { if ($result->is_error) { Bio::KBase::Exceptions::JSONRPC->throw(error => $result->error_message, code => $result->content->{error}->{code}, method_name => 'VSearch_BasicSearch', data => $result->content->{error}->{error} # JSON::RPC::ReturnObject only supports JSONRPC 1.1 or 1.O ); } else { return wantarray ? @{$result->result} : $result->result->[0]; } } else { Bio::KBase::Exceptions::HTTP->throw(error => "Error invoking method VSearch_BasicSearch", status_line => $self->{client}->status_line, method_name => 'VSearch_BasicSearch', ); } } sub version { my ($self) = @_; my $result = $self->{client}->call($self->{url}, $self->{headers}, { method => "kb_vsearch.version", params => [], }); if ($result) { if ($result->is_error) { Bio::KBase::Exceptions::JSONRPC->throw( error => $result->error_message, code => $result->content->{code}, method_name => 'VSearch_BasicSearch', ); } else { return wantarray ? @{$result->result} : $result->result->[0]; } } else { Bio::KBase::Exceptions::HTTP->throw( error => "Error invoking method VSearch_BasicSearch", status_line => $self->{client}->status_line, method_name => 'VSearch_BasicSearch', ); } } sub _validate_version { my ($self) = @_; my $svr_version = $self->version(); my $client_version = $VERSION; my ($cMajor, $cMinor) = split(/\./, $client_version); my ($sMajor, $sMinor) = split(/\./, $svr_version); if ($sMajor != $cMajor) { Bio::KBase::Exceptions::ClientServerIncompatible->throw( error => "Major version numbers differ.", server_version => $svr_version, client_version => $client_version ); } if ($sMinor < $cMinor) { Bio::KBase::Exceptions::ClientServerIncompatible->throw( error => "Client minor version greater than Server minor version.", server_version => $svr_version, client_version => $client_version ); } if ($sMinor > $cMinor) { warn "New client version available for kb_vsearch::kb_vsearchClient\n"; } if ($sMajor == 0) { warn "kb_vsearch::kb_vsearchClient version is $svr_version. API subject to change.\n"; } } =head1 TYPES =head2 workspace_name =over 4 =item Description ** The workspace object refs are of form: ** ** objects = ws.get_objects([{'ref': params['workspace_id']+'/'+params['obj_name']}]) ** ** "ref" means the entire name combining the workspace id and the object name ** "id" is a numerical identifier of the workspace or object, and should just be used for workspace ** "name" is a string identifier of a workspace or object. This is received from Narrative. =item Definition =begin html <pre> a string </pre> =end html =begin text a string =end text =back =head2 sequence =over 4 =item Definition =begin html <pre> a string </pre> =end html =begin text a string =end text =back =head2 data_obj_name =over 4 =item Definition =begin html <pre> a string </pre> =end html =begin text a string =end text =back =head2 data_obj_ref =over 4 =item Definition =begin html <pre> a string </pre> =end html =begin text a string =end text =back =head2 VSearch_BasicSearch_Params =over 4 =item Description VSearch BasicSearch Input Params =item Definition =begin html <pre> a reference to a hash where the following keys are defined: workspace_name has a value which is a kb_vsearch.workspace_name input_one_sequence has a value which is a kb_vsearch.sequence input_one_name has a value which is a kb_vsearch.data_obj_name input_many_name has a value which is a kb_vsearch.data_obj_name output_filtered_name has a value which is a kb_vsearch.data_obj_name maxaccepts has a value which is an int maxrejects has a value which is an int wordlength has a value which is an int minwordmatches has a value which is an int ident_thresh has a value which is a float ident_mode has a value which is an int </pre> =end html =begin text a reference to a hash where the following keys are defined: workspace_name has a value which is a kb_vsearch.workspace_name input_one_sequence has a value which is a kb_vsearch.sequence input_one_name has a value which is a kb_vsearch.data_obj_name input_many_name has a value which is a kb_vsearch.data_obj_name output_filtered_name has a value which is a kb_vsearch.data_obj_name maxaccepts has a value which is an int maxrejects has a value which is an int wordlength has a value which is an int minwordmatches has a value which is an int ident_thresh has a value which is a float ident_mode has a value which is an int =end text =back =head2 VSearch_BasicSearch_Output =over 4 =item Description VSearch BasicSearch Output =item Definition =begin html <pre> a reference to a hash where the following keys are defined: report_name has a value which is a kb_vsearch.data_obj_name report_ref has a value which is a kb_vsearch.data_obj_ref </pre> =end html =begin text a reference to a hash where the following keys are defined: report_name has a value which is a kb_vsearch.data_obj_name report_ref has a value which is a kb_vsearch.data_obj_ref =end text =back =cut package kb_vsearch::kb_vsearchClient::RpcClient; use base 'JSON::RPC::Client'; use POSIX; use strict; # # Override JSON::RPC::Client::call because it doesn't handle error returns properly. # sub call { my ($self, $uri, $headers, $obj) = @_; my $result; { if ($uri =~ /\?/) { $result = $self->_get($uri); } else { Carp::croak "not hashref." unless (ref $obj eq 'HASH'); $result = $self->_post($uri, $headers, $obj); } } my $service = $obj->{method} =~ /^system\./ if ( $obj ); $self->status_line($result->status_line); if ($result->is_success) { return unless($result->content); # notification? if ($service) { return JSON::RPC::ServiceObject->new($result, $self->json); } return JSON::RPC::ReturnObject->new($result, $self->json); } elsif ($result->content_type eq 'application/json') { return JSON::RPC::ReturnObject->new($result, $self->json); } else { return; } } sub _post { my ($self, $uri, $headers, $obj) = @_; my $json = $self->json; $obj->{version} ||= $self->{version} || '1.1'; if ($obj->{version} eq '1.0') { delete $obj->{version}; if (exists $obj->{id}) { $self->id($obj->{id}) if ($obj->{id}); # if undef, it is notification. } else { $obj->{id} = $self->id || ($self->id('JSON::RPC::Client')); } } else { # $obj->{id} = $self->id if (defined $self->id); # Assign a random number to the id if one hasn't been set $obj->{id} = (defined $self->id) ? $self->id : substr(rand(),2); } my $content = $json->encode($obj); $self->ua->post( $uri, Content_Type => $self->{content_type}, Content => $content, Accept => 'application/json', @$headers, ($self->{token} ? (Authorization => $self->{token}) : ()), ); } 1;
dcchivian/kb_vsearch
lib/kb_vsearch/kb_vsearchClient.pm
Perl
mit
13,623
#!/usr/bin/perl # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # $Source: src/usr/targeting/common/genHwsvMrwXml.pl $ # # OpenPOWER HostBoot Project # # Contributors Listed Below - COPYRIGHT 2013,2014 # [+] International Business Machines Corp. # # # 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 # Author: Van Lee vanlee@us.ibm.com # # Usage: # # genHwsvMrwXml.pl --system=systemname --mrwdir=pathname # [--build=hb] [--outfile=XmlFilename] # --system=systemname # Specify which system MRW XML to be generated # --mrwdir=pathname # Specify the complete dir pathname of the MRW. Colon-delimited # list accepted to specify multiple directories to search. # --build=hb # Specify HostBoot build (hb) # --outfile=XmlFilename # Specify the filename for the output XML. If omitted, the output # is written to STDOUT which can be saved by redirection. # # Purpose: # # This perl script processes the various xml files of the MRW to # extract the needed information for generating the final xml file. # use strict; use XML::Simple; use Data::Dumper; ################################################################################ # Set PREFERRED_PARSER to XML::Parser. Otherwise it uses XML::SAX which contains # bugs that result in XML parse errors that can be fixed by adjusting white- # space (i.e. parse errors that do not make sense). ################################################################################ $XML::Simple::PREFERRED_PARSER = 'XML::Parser'; #------------------------------------------------------------------------------ # Constants #------------------------------------------------------------------------------ use constant CHIP_NODE_INDEX => 0; # Position in array of chip's node use constant CHIP_POS_INDEX => 1; # Position in array of chip's position use constant CHIP_ATTR_START_INDEX => 2; # Position in array of start of attrs use constant { MAX_PROC_PER_NODE => 8, MAX_EX_PER_PROC => 16, MAX_ABUS_PER_PROC => 3, MAX_XBUS_PER_PROC => 4, MAX_MCS_PER_PROC => 8, MAX_MBA_PER_MEMBUF => 2, }; our $mrwdir = ""; my $sysname = ""; my $usage = 0; my $DEBUG = 0; my $outFile = ""; my $build = "fsp"; use Getopt::Long; GetOptions( "mrwdir:s" => \$mrwdir, "system:s" => \$sysname, "outfile:s" => \$outFile, "build:s" => \$build, "DEBUG" => \$DEBUG, "help" => \$usage, ); if ($usage || ($mrwdir eq "")) { display_help(); exit 0; } our %hwsvmrw_plugins; # FSP-specific functions if ($build eq "fsp") { eval("use genHwsvMrwXml_fsp; return 1;"); genHwsvMrwXml_fsp::return_plugins(); } if ($outFile ne "") { open OUTFILE, '+>', $outFile || die "ERROR: unable to create $outFile\n"; select OUTFILE; } my $SYSNAME = uc($sysname); my $CHIPNAME = ""; my $MAXNODE = 0; if ($sysname =~ /brazos/) { $MAXNODE = 4; } my $mru_ids_file = open_mrw_file($mrwdir, "${sysname}-mru-ids.xml"); my $mruAttr = parse_xml_file($mru_ids_file); #------------------------------------------------------------------------------ # Process the system-policy MRW file #------------------------------------------------------------------------------ my $system_policy_file = open_mrw_file($mrwdir, "${sysname}-system-policy.xml"); my $sysPolicy = parse_xml_file($system_policy_file); my $reqPol = $sysPolicy->{"required-policy-settings"}; my @systemAttr; # Repeated {ATTR, VAL, ATTR, VAL, ATTR, VAL...} #No mirroring supported yet so the policy is just based on multi-node or not my $placement = 0x0; #NORMAL if ($sysname =~ /brazos/) { $placement = 0x3; #DRAWER } push @systemAttr, [ "FREQ_PROC_REFCLOCK", $reqPol->{'processor-refclock-frequency'}->{content}, "FREQ_PROC_REFCLOCK_KHZ", $reqPol->{'processor-refclock-frequency-khz'}->{content}, "FREQ_MEM_REFCLOCK", $reqPol->{'memory-refclock-frequency'}->{content}, "BOOT_FREQ_MHZ", $reqPol->{'boot-frequency'}->{content}, "FREQ_A", $reqPol->{'proc_a_frequency'}->{content}, "FREQ_PB", $reqPol->{'proc_pb_frequency'}->{content}, "NEST_FREQ_MHZ", $reqPol->{'proc_pb_frequency'}->{content}, "FREQ_PCIE", $reqPol->{'proc_pcie_frequency'}->{content}, "FREQ_X", $reqPol->{'proc_x_frequency'}->{content}, "MSS_MBA_ADDR_INTERLEAVE_BIT", $reqPol->{'mss_mba_addr_interleave_bit'}, "MSS_MBA_CACHELINE_INTERLEAVE_MODE", $reqPol->{'mss_mba_cacheline_interleave_mode'}, "PROC_EPS_TABLE_TYPE", $reqPol->{'proc_eps_table_type'}, "PROC_FABRIC_PUMP_MODE", $reqPol->{'proc_fabric_pump_mode'}, "PROC_X_BUS_WIDTH", $reqPol->{'proc_x_bus_width'}, "X_EREPAIR_THRESHOLD_FIELD", $reqPol->{'x-erepair-threshold-field'}, "A_EREPAIR_THRESHOLD_FIELD", $reqPol->{'a-erepair-threshold-field'}, "DMI_EREPAIR_THRESHOLD_FIELD", $reqPol->{'dmi-erepair-threshold-field'}, "X_EREPAIR_THRESHOLD_MNFG", $reqPol->{'x-erepair-threshold-mnfg'}, "A_EREPAIR_THRESHOLD_MNFG", $reqPol->{'a-erepair-threshold-mnfg'}, "DMI_EREPAIR_THRESHOLD_MNFG", $reqPol->{'dmi-erepair-threshold-mnfg'}, "MRW_SAFEMODE_MEM_THROTTLE_NUMERATOR_PER_MBA", $reqPol->{'safemode_mem_throttle_numerator_per_mba'}, "MRW_SAFEMODE_MEM_THROTTLE_DENOMINATOR", $reqPol->{'safemode_mem_throttle_denominator'}, "MRW_SAFEMODE_MEM_THROTTLE_NUMERATOR_PER_CHIP", $reqPol->{'safemode_mem_throttle_numerator_per_chip'}, "MRW_THERMAL_MEMORY_POWER_LIMIT", $reqPol->{'thermal_memory_power_limit'}, "MSS_MBA_ADDR_INTERLEAVE_BIT", $reqPol->{'mss_mba_addr_interleave_bit'}, "MSS_MBA_CACHELINE_INTERLEAVE_MODE", $reqPol->{'mss_mba_cacheline_interleave_mode'}, "PM_EXTERNAL_VRM_STEPSIZE", $reqPol->{'pm_external_vrm_stepsize'}, "PM_EXTERNAL_VRM_STEPDELAY", $reqPol->{'pm_external_vrm_stepdelay'}, "PM_SPIVID_FREQUENCY", $reqPol->{'pm_spivid_frequency'}->{content}, "PM_SAFE_FREQUENCY", $reqPol->{'pm_safe_frequency'}->{content}, "PM_RESONANT_CLOCK_FULL_CLOCK_SECTOR_BUFFER_FREQUENCY", $reqPol->{'pm_resonant_clock_full_clock_sector_buffer_frequency'}-> {content}, "PM_RESONANT_CLOCK_LOW_BAND_LOWER_FREQUENCY", $reqPol->{'pm_resonant_clock_low_band_lower_frequency'}->{content}, "PM_RESONANT_CLOCK_LOW_BAND_UPPER_FREQUENCY", $reqPol->{'pm_resonant_clock_low_band_upper_frequency'}->{content}, "PM_RESONANT_CLOCK_HIGH_BAND_LOWER_FREQUENCY", $reqPol->{'pm_resonant_clock_high_band_lower_frequency'}->{content}, "PM_RESONANT_CLOCK_HIGH_BAND_UPPER_FREQUENCY", $reqPol->{'pm_resonant_clock_high_band_upper_frequency'}->{content}, "PM_SPIPSS_FREQUENCY", $reqPol->{'pm_spipss_frequency'}->{content}, "PROC_R_LOADLINE_VDD", $reqPol->{'proc_r_loadline_vdd'}, "PROC_R_DISTLOSS_VDD", $reqPol->{'proc_r_distloss_vdd'}, "PROC_VRM_VOFFSET_VDD", $reqPol->{'proc_vrm_voffset_vdd'}, "PROC_R_LOADLINE_VCS", $reqPol->{'proc_r_loadline_vcs'}, "PROC_R_DISTLOSS_VCS", $reqPol->{'proc_r_distloss_vcs'}, "PROC_VRM_VOFFSET_VCS", $reqPol->{'proc_vrm_voffset_vcs'}, "MEM_MIRROR_PLACEMENT_POLICY", $placement, "MRW_DIMM_POWER_CURVE_PERCENT_UPLIFT", $reqPol->{'dimm_power_curve_percent_uplift'}, "MRW_MEM_THROTTLE_DENOMINATOR", $reqPol->{'mem_throttle_denominator'}, "MRW_MAX_DRAM_DATABUS_UTIL", $reqPol->{'max_dram_databus_util'}, "MRW_CDIMM_MASTER_I2C_TEMP_SENSOR_ENABLE", $reqPol->{'cdimm_master_i2c_temp_sensor_enable'}, "MRW_CDIMM_SPARE_I2C_TEMP_SENSOR_ENABLE", $reqPol->{'cdimm_spare_i2c_temp_sensor_enable'}, "PM_SYSTEM_IVRMS_ENABLED", $reqPol->{'pm_system_ivrms_enabled'}, "PM_SYSTEM_IVRM_VPD_MIN_LEVEL", $reqPol->{'pm_system_ivrm_vpd_min_level'}, "MRW_ENHANCED_GROUPING_NO_MIRRORING", $reqPol->{'mcs_enhanced_grouping_no_mirroring'}, "MRW_STRICT_MBA_PLUG_RULE_CHECKING", $reqPol->{'strict_mba_plug_rule_checking'}, "MNFG_DMI_MIN_EYE_WIDTH", $reqPol->{'mnfg-dmi-min-eye-width'}, "MNFG_DMI_MIN_EYE_HEIGHT", $reqPol->{'mnfg-dmi-min-eye-height'}, "MNFG_ABUS_MIN_EYE_WIDTH", $reqPol->{'mnfg-abus-min-eye-width'}, "MNFG_ABUS_MIN_EYE_HEIGHT", $reqPol->{'mnfg-abus-min-eye-height'}, "MNFG_XBUS_MIN_EYE_WIDTH", $reqPol->{'mnfg-xbus-min-eye-width'}, "REDUNDANT_CLOCKS", $reqPol->{'redundant-clocks'}, ]; if ($reqPol->{'mba_cacheline_interleave_mode_control'} eq 'required') { push @systemAttr, ["MRW_MBA_CACHELINE_INTERLEAVE_MODE_CONTROL", 1]; } elsif ($reqPol->{'mba_cacheline_interleave_mode_control'} eq 'requested') { push @systemAttr, ["MRW_MBA_CACHELINE_INTERLEAVE_MODE_CONTROL", 2]; } else { push @systemAttr, ["MRW_MBA_CACHELINE_INTERLEAVE_MODE_CONTROL", 0]; } if ($MAXNODE > 1 && $sysname !~ m/mfg/) { push @systemAttr, ["DO_ABUS_DECONFIG", 0]; } # Process optional policies related to dyanmic VID my $optMrwPolicies = $sysPolicy->{"optional-policy-settings"}; use constant MRW_NAME => 'mrw-name'; my %optTargPolicies = (); $optTargPolicies{'MSS_CENT_AVDD_OFFSET_DISABLE'}{MRW_NAME} = "mem_avdd_offset_disable" ; $optTargPolicies{'MSS_CENT_VDD_OFFSET_DISABLE'}{MRW_NAME} = "mem_vdd_offset_disable" ; $optTargPolicies{'MSS_CENT_VCS_OFFSET_DISABLE'}{MRW_NAME} = "mem_vcs_offset_disable" ; $optTargPolicies{'MSS_VOLT_VPP_OFFSET_DISABLE'}{MRW_NAME} = "mem_vpp_offset_disable" ; $optTargPolicies{'MSS_VOLT_VDDR_OFFSET_DISABLE'}{MRW_NAME} = "mem_vddr_offset_disable" ; $optTargPolicies{'MSS_CENT_AVDD_SLOPE_ACTIVE'}{MRW_NAME} = "mem_avdd_slope_active" ; $optTargPolicies{'MSS_CENT_AVDD_SLOPE_INACTIVE'}{MRW_NAME} = "mem_avdd_slope_inactive" ; $optTargPolicies{'MSS_CENT_AVDD_INTERCEPT'}{MRW_NAME} = "mem_avdd_intercept" ; $optTargPolicies{'MSS_CENT_VDD_SLOPE_ACTIVE'}{MRW_NAME} = "mem_vdd_slope_active" ; $optTargPolicies{'MSS_CENT_VDD_SLOPE_INACTIVE'}{MRW_NAME} = "mem_vdd_slope_inactive" ; $optTargPolicies{'MSS_CENT_VDD_INTERCEPT'}{MRW_NAME} = "mem_vdd_intercept" ; $optTargPolicies{'MSS_CENT_VCS_SLOPE_ACTIVE'}{MRW_NAME} = "mem_vcs_slope_active" ; $optTargPolicies{'MSS_CENT_VCS_SLOPE_INACTIVE'}{MRW_NAME} = "mem_vcs_slope_inactive" ; $optTargPolicies{'MSS_CENT_VCS_INTERCEPT'}{MRW_NAME} = "mem_vcs_intercept" ; $optTargPolicies{'MSS_VOLT_VPP_SLOPE'}{MRW_NAME} = "mem_vpp_slope" ; $optTargPolicies{'MSS_VOLT_VPP_INTERCEPT'}{MRW_NAME} = "mem_vpp_intercept" ; $optTargPolicies{'MSS_VOLT_DDR3_VDDR_SLOPE'}{MRW_NAME} = "mem_ddr3_vddr_slope" ; $optTargPolicies{'MSS_VOLT_DDR3_VDDR_INTERCEPT'}{MRW_NAME} = "mem_ddr3_vddr_intercept" ; $optTargPolicies{'MSS_VOLT_DDR4_VDDR_SLOPE'}{MRW_NAME} = "mem_ddr4_vddr_slope" ; $optTargPolicies{'MSS_VOLT_DDR4_VDDR_INTERCEPT'}{MRW_NAME} = "mem_ddr4_vddr_intercept" ; foreach my $policy ( keys %optTargPolicies ) { if(exists $optMrwPolicies->{ $optTargPolicies{$policy}{MRW_NAME}}) { push @systemAttr, [ $policy , $optMrwPolicies->{$optTargPolicies{$policy}{MRW_NAME}}]; } } #------------------------------------------------------------------------------ # Process the pm-settings MRW file #------------------------------------------------------------------------------ my $pm_settings_file = open_mrw_file($mrwdir, "${sysname}-pm-settings.xml"); my $pmSettings = parse_xml_file($pm_settings_file); my @pmChipAttr; # Repeated [NODE, POS, ATTR, VAL, ATTR, VAL, ATTR, VAL...] foreach my $i (@{$pmSettings->{'processor-settings'}}) { push @pmChipAttr, [ $i->{target}->{node}, $i->{target}->{position}, "PM_UNDERVOLTING_FRQ_MINIMUM", $i->{pm_undervolting_frq_minimum}->{content}, "PM_UNDERVOLTING_FREQ_MAXIMUM", $i->{pm_undervolting_frq_maximum}->{content}, "PM_SPIVID_PORT_ENABLE", $i->{pm_spivid_port_enable}, "PM_APSS_CHIP_SELECT", $i->{pm_apss_chip_select}, "PM_PBAX_NODEID", $i->{pm_pbax_nodeid}, "PM_PBAX_CHIPID", $i->{pm_pbax_chipid}, "PM_PBAX_BRDCST_ID_VECTOR", $i->{pm_pbax_brdcst_id_vector}, "PM_SLEEP_ENTRY", $i->{pm_sleep_entry}, "PM_SLEEP_EXIT", $i->{pm_sleep_exit}, "PM_SLEEP_TYPE", $i->{pm_sleep_type}, "PM_WINKLE_ENTRY", $i->{pm_winkle_entry}, "PM_WINKLE_EXIT", $i->{pm_winkle_exit}, "PM_WINKLE_TYPE", $i->{pm_winkle_type}, ] } my @SortedPmChipAttr = sort byNodePos @pmChipAttr; if ((scalar @SortedPmChipAttr) == 0) { # For all systems without a populated <sys>-pm-settings file, this script # defaults the values. # Orlena: Platform dropped so there will never be a populated # orlena-pm-settings file # Brazos: SW231069 raised to get brazos-pm-settings populated print STDOUT "WARNING: No data in mrw dir(s): $mrwdir with ". "filename:${sysname}-pm-settings.xml. Defaulting values\n"; } #------------------------------------------------------------------------------ # Process the proc-pcie-settings MRW file #------------------------------------------------------------------------------ my $proc_pcie_settings_file = open_mrw_file($mrwdir, "${sysname}-proc-pcie-settings.xml"); my $ProcPcie = parse_xml_file($proc_pcie_settings_file); # Repeated [NODE, POS, ATTR, IOP0-VAL, IOP1-VAL, ATTR, IOP0-VAL, IOP1-VAL] my @procPcie; foreach my $i (@{$ProcPcie->{'processor-settings'}}) { push @procPcie, [$i->{target}->{node}, $i->{target}->{position}, "PROC_PCIE_IOP_G2_PLL_CONTROL0", $i->{proc_pcie_iop_g2_pll_control0_iop0}, $i->{proc_pcie_iop_g2_pll_control0_iop1}, "PROC_PCIE_IOP_G3_PLL_CONTROL0", $i->{proc_pcie_iop_g3_pll_control0_iop0}, $i->{proc_pcie_iop_g3_pll_control0_iop1}, "PROC_PCIE_IOP_PCS_CONTROL0", $i->{proc_pcie_iop_pcs_control0_iop0}, $i->{proc_pcie_iop_pcs_control0_iop1}, "PROC_PCIE_IOP_PCS_CONTROL1", $i->{proc_pcie_iop_pcs_control1_iop0}, $i->{proc_pcie_iop_pcs_control1_iop1}, "PROC_PCIE_IOP_PLL_GLOBAL_CONTROL0", $i->{proc_pcie_iop_pll_global_control0_iop0}, $i->{proc_pcie_iop_pll_global_control0_iop1}, "PROC_PCIE_IOP_PLL_GLOBAL_CONTROL1", $i->{proc_pcie_iop_pll_global_control1_iop0}, $i->{proc_pcie_iop_pll_global_control1_iop1}, "PROC_PCIE_IOP_RX_PEAK", $i->{proc_pcie_iop_rx_peak_iop0}, $i->{proc_pcie_iop_rx_peak_iop1}, "PROC_PCIE_IOP_RX_SDL", $i->{proc_pcie_iop_rx_sdl_iop0}, $i->{proc_pcie_iop_rx_sdl_iop1}, "PROC_PCIE_IOP_RX_VGA_CONTROL2", $i->{proc_pcie_iop_rx_vga_control2_iop0}, $i->{proc_pcie_iop_rx_vga_control2_iop1}, "PROC_PCIE_IOP_TX_BWLOSS1", $i->{proc_pcie_iop_tx_bwloss1_iop0}, $i->{proc_pcie_iop_tx_bwloss1_iop1}, "PROC_PCIE_IOP_TX_FIFO_OFFSET", $i->{proc_pcie_iop_tx_fifo_offset_iop0}, $i->{proc_pcie_iop_tx_fifo_offset_iop1}, "PROC_PCIE_IOP_TX_RCVRDETCNTL", $i->{proc_pcie_iop_tx_rcvrdetcntl_iop0}, $i->{proc_pcie_iop_tx_rcvrdetcntl_iop1}, "PROC_PCIE_IOP_ZCAL_CONTROL", $i->{proc_pcie_iop_zcal_control_iop0}, $i->{proc_pcie_iop_zcal_control_iop1}]; } my @SortedPcie = sort byNodePos @procPcie; #------------------------------------------------------------------------------ # Process the chip-ids MRW file #------------------------------------------------------------------------------ my $chip_ids_file = open_mrw_file($mrwdir, "${sysname}-chip-ids.xml"); my $chipIds = parse_xml_file($chip_ids_file); use constant CHIP_ID_NODE => 0; use constant CHIP_ID_POS => 1; use constant CHIP_ID_PATH => 2; use constant CHIP_ID_NXPX => 3; my @chipIDs; foreach my $i (@{$chipIds->{'chip-id'}}) { push @chipIDs, [ $i->{node}, $i->{position}, $i->{'instance-path'}, "n$i->{target}->{node}:p$i->{target}->{position}" ]; } #------------------------------------------------------------------------------ # Process the power-busses MRW file #------------------------------------------------------------------------------ my $power_busses_file = open_mrw_file($mrwdir, "${sysname}-power-busses.xml"); my $powerbus = parse_xml_file($power_busses_file); my @pbus; use constant PBUS_FIRST_END_POINT_INDEX => 0; use constant PBUS_SECOND_END_POINT_INDEX => 1; use constant PBUS_DOWNSTREAM_INDEX => 2; use constant PBUS_UPSTREAM_INDEX => 3; use constant PBUS_TX_MSB_LSB_SWAP => 4; use constant PBUS_RX_MSB_LSB_SWAP => 5; use constant PBUS_ENDPOINT_INSTANCE_PATH => 6; use constant PBUS_NODE_CONFIG_FLAG => 7; foreach my $i (@{$powerbus->{'power-bus'}}) { # Pull out the connection information from the description # example: n0:p0:A2 to n0:p2:A2 my $endp1 = $i->{'description'}; my $endp2 = "null"; my $dwnstrm_swap = 0; my $upstrm_swap = 0; my $nodeconfig = "null"; my $present = index $endp1, 'not connected'; if ($present eq -1) { $endp2 = $endp1; $endp1 =~ s/^(.*) to.*/$1/; $endp2 =~ s/.* to (.*)\s*$/$1/; # Grab the lane swap information $dwnstrm_swap = $i->{'downstream-n-p-lane-swap-mask'}; $upstrm_swap = $i->{'upstream-n-p-lane-swap-mask'}; # Abort if node config information is not found if(!(exists $i->{'include-for-node-config'})) { die "include-for-node-config element not found "; } $nodeconfig = $i->{'include-for-node-config'}; } else { $endp1 =~ s/^(.*) unit.*/$1/; $endp2 = "invalid"; # Set the lane swap information to 0 to avoid junk $dwnstrm_swap = 0; $upstrm_swap = 0; } my $bustype = $endp1; $bustype =~ s/.*:p.*:(.).*/$1/; my $tx_swap = 0; my $rx_swap = 0; if (lc($bustype) eq "a") { $tx_swap = $i->{'tx-msb-lsb-swap'}; $rx_swap = $i->{'rx-msb-lsb-swap'}; $tx_swap = ($tx_swap eq "false") ? 0 : 1; $rx_swap = ($rx_swap eq "false") ? 0 : 1; } my $endpoint1_ipath = $i->{'endpoint'}[0]->{'instance-path'}; my $endpoint2_ipath = $i->{'endpoint'}[1]->{'instance-path'}; #print STDOUT "powerbus: $endp1, $endp2, $dwnstrm_swap, $upstrm_swap\n"; # Brazos: Populate power bus list only for "2-node" & "all" configuration # for ABUS. Populate all entries for other bus type. # Other targets(tuleta, alphine..etc) : nodeconfig will be "all". if ( (lc($bustype) ne "a") || ($nodeconfig eq "2-node") || ($nodeconfig eq "all") ) { push @pbus, [ lc($endp1), lc($endp2), $dwnstrm_swap, $upstrm_swap, $tx_swap, $rx_swap, $endpoint1_ipath, $nodeconfig ]; push @pbus, [ lc($endp2), lc($endp1), $dwnstrm_swap, $upstrm_swap, $tx_swap, $rx_swap, $endpoint2_ipath, $nodeconfig ]; } } #------------------------------------------------------------------------------ # Process the dmi-busses MRW file #------------------------------------------------------------------------------ my $dmi_busses_file = open_mrw_file($mrwdir, "${sysname}-dmi-busses.xml"); my $dmibus = parse_xml_file($dmi_busses_file); my @dbus_mcs; use constant DBUS_MCS_NODE_INDEX => 0; use constant DBUS_MCS_PROC_INDEX => 1; use constant DBUS_MCS_UNIT_INDEX => 2; use constant DBUS_MCS_DOWNSTREAM_INDEX => 3; use constant DBUS_MCS_TX_SWAP_INDEX => 4; use constant DBUS_MCS_RX_SWAP_INDEX => 5; use constant DBUS_MCS_SWIZZLE_INDEX => 6; my @dbus_centaur; use constant DBUS_CENTAUR_NODE_INDEX => 0; use constant DBUS_CENTAUR_MEMBUF_INDEX => 1; use constant DBUS_CENTAUR_UPSTREAM_INDEX => 2; use constant DBUS_CENTAUR_TX_SWAP_INDEX => 3; use constant DBUS_CENTAUR_RX_SWAP_INDEX => 4; foreach my $dmi (@{$dmibus->{'dmi-bus'}}) { # First grab the MCS information # MCS is always master so it gets downstream my $node = $dmi->{'mcs'}->{'target'}->{'node'}; my $proc = $dmi->{'mcs'}->{'target'}->{'position'}; my $mcs = $dmi->{'mcs'}->{'target'}->{'chipUnit'}; my $swap = $dmi->{'downstream-n-p-lane-swap-mask'}; my $tx_swap = $dmi->{'tx-msb-lsb-swap'}; my $rx_swap = $dmi->{'rx-msb-lsb-swap'}; $tx_swap = ($tx_swap eq "false") ? 0 : 1; $rx_swap = ($rx_swap eq "false") ? 0 : 1; my $swizzle = $dmi->{'mcs-refclock-enable-mapping'}; #print STDOUT "dbus_mcs: n$node:p$proc:mcs:$mcs swap:$swap\n"; push @dbus_mcs, [ $node, $proc, $mcs, $swap, $tx_swap, $rx_swap, $swizzle ]; # Now grab the centuar chip information # Centaur is always slave so it gets upstream my $node = $dmi->{'centaur'}->{'target'}->{'node'}; my $membuf = $dmi->{'centaur'}->{'target'}->{'position'}; my $swap = $dmi->{'upstream-n-p-lane-swap-mask'}; my $tx_swap = $dmi->{'rx-msb-lsb-swap'}; my $rx_swap = $dmi->{'tx-msb-lsb-swap'}; $tx_swap = ($tx_swap eq "false") ? 0 : 1; $rx_swap = ($rx_swap eq "false") ? 0 : 1; #print STDOUT "dbus_centaur: n$node:cen$membuf swap:$swap\n"; push @dbus_centaur, [ $node, $membuf, $swap, $tx_swap, $rx_swap ]; } #------------------------------------------------------------------------------ # Process the cent-vrds MRW file #------------------------------------------------------------------------------ my $cent_vrds_file = open_mrw_file($mrwdir, "${sysname}-cent-vrds.xml"); my $mrwMemVoltageDomains = parse_xml_file($cent_vrds_file); our %vrmHash = (); my %membufVrmUuidHash = (); my %vrmIdHash = (); my %validVrmTypes = ('VMEM' => 1,'AVDD' => 1,'VCS' => 1,'VPP' => 1,'VDD' => 1); use constant VRM_I2C_DEVICE_PATH => 'vrmI2cDevicePath'; use constant VRM_I2C_ADDRESS => 'vrmI2cAddress'; use constant VRM_DOMAIN_TYPE => 'vrmDomainType'; use constant VRM_DOMAIN_ID => 'vrmDomainId'; use constant VRM_UUID => 'vrmUuid'; foreach my $mrwMemVoltageDomain ( @{$mrwMemVoltageDomains->{'centaur-vrd-connection'}}) { if( (!exists $mrwMemVoltageDomain->{'vrd'}->{'i2c-dev-path'}) || (!exists $mrwMemVoltageDomain->{'vrd'}->{'i2c-address'}) || (ref($mrwMemVoltageDomain->{'vrd'}->{'i2c-dev-path'}) eq "HASH") || (ref($mrwMemVoltageDomain->{'vrd'}->{'i2c-address'}) eq "HASH") || ($mrwMemVoltageDomain->{'vrd'}->{'i2c-dev-path'} eq "") || ($mrwMemVoltageDomain->{'vrd'}->{'i2c-address'} eq "")) { next; } my $vrmDev = $mrwMemVoltageDomain->{'vrd'}->{'i2c-dev-path'}; my $vrmAddr = $mrwMemVoltageDomain->{'vrd'}->{'i2c-address'}; my $vrmType = uc $mrwMemVoltageDomain->{'vrd'}->{'type'}; my $membufInstance = "n" . $mrwMemVoltageDomain->{'centaur'}->{'target'}->{'node'} . ":p" . $mrwMemVoltageDomain->{'centaur'}->{'target'}->{'position'}; if(!exists $validVrmTypes{$vrmType}) { die "Illegal VRM type of $vrmType used\n"; } if(!exists $vrmIdHash{$vrmType}) { $vrmIdHash{$vrmType} = 0; } my $uuid = -1; foreach my $vrm ( keys %vrmHash ) { if( ($vrmHash{$vrm}{VRM_I2C_DEVICE_PATH} eq $vrmDev ) && ($vrmHash{$vrm}{VRM_I2C_ADDRESS} eq $vrmAddr) && ($vrmHash{$vrm}{VRM_DOMAIN_TYPE} eq $vrmType) ) { $uuid = $vrm; last; } } if($uuid == -1) { my $vrm = scalar keys %vrmHash; $vrmHash{$vrm}{VRM_I2C_DEVICE_PATH} = $vrmDev; $vrmHash{$vrm}{VRM_I2C_ADDRESS} = $vrmAddr; $vrmHash{$vrm}{VRM_DOMAIN_TYPE} = $vrmType; $vrmHash{$vrm}{VRM_DOMAIN_ID} = $vrmIdHash{$vrmType}++; $uuid = $vrm; } $membufVrmUuidHash{$membufInstance}{$vrmType}{VRM_UUID} = $uuid; } my $vrmDebug = 0; if($vrmDebug) { foreach my $membuf ( keys %membufVrmUuidHash) { print STDOUT "Membuf instance: " . $membuf . "\n"; foreach my $vrmType ( keys %{$membufVrmUuidHash{$membuf}} ) { print STDOUT "VRM type: " . $vrmType . "\n"; print STDOUT "VRM UUID: " . $membufVrmUuidHash{$membuf}{$vrmType}{VRM_UUID} . "\n"; } } foreach my $vrm ( keys %vrmHash) { print STDOUT "VRM UUID: " . $vrm . "\n"; print STDOUT "VRM type: " . $vrmHash{$vrm}{VRM_DOMAIN_TYPE} . "\n"; print STDOUT "VRM id: " . $vrmHash{$vrm}{VRM_DOMAIN_ID} . "\n"; print STDOUT "VRM dev: " . $vrmHash{$vrm}{VRM_I2C_DEVICE_PATH} . "\n"; print STDOUT "VRM addr: " . $vrmHash{$vrm}{VRM_I2C_ADDRESS} . "\n"; } } #------------------------------------------------------------------------------ # Process the cec-chips and pcie-busses MRW files #------------------------------------------------------------------------------ my $cec_chips_file = open_mrw_file($mrwdir, "${sysname}-cec-chips.xml"); my $devpath = parse_xml_file($cec_chips_file, KeyAttr=>'instance-path'); my $pcie_busses_file = open_mrw_file($mrwdir, "${sysname}-pcie-busses.xml"); my $pcie_buses = parse_xml_file($pcie_busses_file); our %pcie_list; foreach my $pcie_bus (@{$pcie_buses->{'pcie-bus'}}) { if(!exists($pcie_bus->{'switch'})) { foreach my $lane_set (0,1) { $pcie_list{$pcie_bus->{source}->{'instance-path'}}->{$pcie_bus-> {source}->{iop}}->{$lane_set}-> {'lane-mask'} = 0; $pcie_list{$pcie_bus->{source}->{'instance-path'}}->{$pcie_bus-> {source}->{iop}}->{$lane_set}-> {'dsmp-capable'} = 0; $pcie_list{$pcie_bus->{source}->{'instance-path'}}->{$pcie_bus-> {source}->{iop}}->{$lane_set}-> {'lane-swap'} = 0; $pcie_list{$pcie_bus->{source}->{'instance-path'}}->{$pcie_bus-> {source}->{iop}}->{$lane_set}-> {'lane-reversal'} = 0; $pcie_list{$pcie_bus->{source}->{'instance-path'}}->{$pcie_bus-> {source}->{iop}}->{$lane_set}-> {'is-slot'} = 0; } } } foreach my $pcie_bus (@{$pcie_buses->{'pcie-bus'}}) { if(!exists($pcie_bus->{'switch'})) { my $dsmp_capable = 0; my $is_slot = 0; if((exists($pcie_bus->{source}->{'dsmp-capable'}))&& ($pcie_bus->{source}->{'dsmp-capable'} eq 'Yes')) { $dsmp_capable = 1; } if((exists($pcie_bus->{endpoint}->{'is-slot'}))&& ($pcie_bus->{endpoint}->{'is-slot'} eq 'Yes')) { $is_slot = 1; } my $lane_set = 0; if(($pcie_bus->{source}->{'lane-mask'} eq '0xFFFF')|| ($pcie_bus->{source}->{'lane-mask'} eq '0xFF00')) { $lane_set = 0; } else { if($pcie_bus->{source}->{'lane-mask'} eq '0x00FF') { $lane_set = 1; } } $pcie_list{$pcie_bus->{source}->{'instance-path'}}-> {$pcie_bus->{source}->{iop}}->{$lane_set}->{'lane-mask'} = $pcie_bus->{source}->{'lane-mask'}; $pcie_list{$pcie_bus->{source}->{'instance-path'}}-> {$pcie_bus->{source}->{iop}}->{$lane_set}->{'dsmp-capable'} = $dsmp_capable; $pcie_list{$pcie_bus->{source}->{'instance-path'}}-> {$pcie_bus->{source}->{iop}}->{$lane_set}->{'lane-swap'} = oct($pcie_bus->{source}->{'lane-swap-bits'}); $pcie_list{$pcie_bus->{source}->{'instance-path'}}-> {$pcie_bus->{source}->{iop}}->{$lane_set}->{'lane-reversal'} = oct($pcie_bus->{source}->{'lane-reversal-bits'}); $pcie_list{$pcie_bus->{source}->{'instance-path'}}-> {$pcie_bus->{source}->{iop}}->{$lane_set}->{'is-slot'} = $is_slot; } } our %bifurcation_list; foreach my $pcie_bus (@{$pcie_buses->{'pcie-bus'}}) { if(!exists($pcie_bus->{'switch'})) { foreach my $lane_set (0,1) { $bifurcation_list{$pcie_bus->{source}->{'instance-path'}}-> {$pcie_bus->{source}->{iop}}->{$lane_set}->{'lane-mask'}= 0; $bifurcation_list{$pcie_bus->{source}->{'instance-path'}}-> {$pcie_bus->{source}->{iop}}->{$lane_set}->{'lane-swap'}= 0; $bifurcation_list{$pcie_bus->{source}->{'instance-path'}}-> {$pcie_bus->{source}->{iop}}->{$lane_set}->{'lane-reversal'}= 0; } } } foreach my $pcie_bus (@{$pcie_buses->{'pcie-bus'}}) { if( (!exists($pcie_bus->{'switch'})) && (exists($pcie_bus->{source}->{'bifurcation-settings'}))) { my $bi_cnt = 0; foreach my $bifurc (@{$pcie_bus->{source}->{'bifurcation-settings'}-> {'bifurcation-setting'}}) { my $lane_swap = 0; $bifurcation_list{$pcie_bus->{source}->{'instance-path'}}-> {$pcie_bus->{source}->{iop}}{$bi_cnt}-> {'lane-mask'} = $bifurc->{'lane-mask'}; $bifurcation_list{$pcie_bus->{source}->{'instance-path'}}-> {$pcie_bus->{source}->{iop}}{$bi_cnt}-> {'lane-swap'} = oct($bifurc->{'lane-swap-bits'}); $bifurcation_list{$pcie_bus->{source}->{'instance-path'}}-> {$pcie_bus->{source}->{iop}}{$bi_cnt}-> {'lane-reversal'} = oct($bifurc-> {'lane-reversal-bits'}); $bi_cnt++; } } } #------------------------------------------------------------------------------ # Process the targets MRW file #------------------------------------------------------------------------------ my $targets_file = open_mrw_file($mrwdir, "${sysname}-targets.xml"); my $eTargets = parse_xml_file($targets_file); # Capture all targets into the @Targets array use constant NAME_FIELD => 0; use constant NODE_FIELD => 1; use constant POS_FIELD => 2; use constant UNIT_FIELD => 3; use constant PATH_FIELD => 4; use constant LOC_FIELD => 5; use constant ORDINAL_FIELD => 6; use constant FRU_PATH => 7; use constant PLUG_POS => 8; my @Targets; foreach my $i (@{$eTargets->{target}}) { my $plugPosition = $i->{'plug-xpath'}; my $frupath = ""; $plugPosition =~ s/.*mrw:position\/text\(\)=\'(.*)\'\]$/$1/; if (exists $devpath->{chip}->{$i->{'instance-path'}}->{'fru-instance-path'}) { $frupath = $devpath->{chip}->{$i->{'instance-path'}}-> {'fru-instance-path'}; } push @Targets, [ $i->{'ecmd-common-name'}, $i->{node}, $i->{position}, $i->{'chip-unit'}, $i->{'instance-path'}, $i->{location}, 0,$frupath, $plugPosition ]; if (($i->{'ecmd-common-name'} eq "pu") && ($CHIPNAME eq "")) { $CHIPNAME = $i->{'description'}; $CHIPNAME =~ s/Instance of (.*) cpu/$1/g; $CHIPNAME = lc($CHIPNAME); } } #------------------------------------------------------------------------------ # Process the fsi-busses MRW file #------------------------------------------------------------------------------ my $fsi_busses_file = open_mrw_file($mrwdir, "${sysname}-fsi-busses.xml"); my $fsiBus = parse_xml_file($fsi_busses_file); # Build all the FSP chip targets / attributes my %FSPs = (); foreach my $fsiBus (@{$fsiBus->{'fsi-bus'}}) { # FSP always has master type of FSP master; Add unique ones my $instancePathKey = $fsiBus->{master}->{'instance-path'}; if ( (lc($fsiBus->{master}->{type}) eq "fsp master") && !(exists($FSPs{$instancePathKey}))) { my $node = $fsiBus->{master}->{target}->{node}; my $position = $fsiBus->{master}->{target}->{position}; my $huid = sprintf("0x%02X15%04X",$node,$position); my $rid = sprintf("0x%08X", 0x200 + $position); my $sys = "0"; $FSPs{$instancePathKey} = { 'sys' => $sys, 'node' => $node, 'position' => $position, 'ordinalId' => $position, 'instancePath'=> $fsiBus->{master}->{'instance-path'}, 'huid' => $huid, 'rid' => $rid, }; } } # Build up FSI paths # Capture all FSI connections into the @Fsis array my @Fsis; use constant FSI_TYPE_FIELD => 0; use constant FSI_LINK_FIELD => 1; use constant FSI_TARGET_FIELD => 2; use constant FSI_MASTERNODE_FIELD => 3; use constant FSI_MASTERPOS_FIELD => 4; use constant FSI_TARGET_TYPE_FIELD => 5; use constant FSI_SLAVE_PORT_FIELD => 6; #Master procs have FSP as their master #<fsi-bus> # <master> # <type>FSP Master</type> # <part-id>BRAZOS_FSP2</part-id> # <unit-id>FSIM_CLK[23]</unit-id> # <target><name>fsp</name><node>4</node><position>1</position></target> # <engine>0</engine> # <link>23</link> # </master> # <slave> # <part-id>VENICE</part-id> # <unit-id>FSI_SLAVE0</unit-id> # <target><name>pu</name><node>3</node><position>1</position></target> # <port>0</port> # </slave> #</fsi-bus> #Non-master chips have a MURANO/VENICE as their master #<fsi-bus> # <master> # <part-id>VENICE</part-id> # <unit-id>FSI_CASCADE3</unit-id> # <target><name>pu</name><node>0</node><position>0</position></target> # <engine>12</engine> # <link>3</link> # <type>Cascaded Master</type> # </master> # <slave> # <part-id>CENTAUR</part-id> # <unit-id>FSI_SLAVE0</unit-id> # <target><name>memb</name><node>0</node><position>0</position></target> # <fsp-device-path-segments>L02C0E12:L3C0</fsp-device-path-segments> # <port>0</port> # </slave> #</fsi-bus> foreach my $fsiBus (@{$fsiBus->{'fsi-bus'}}) { #skip slaves that we don't care about if( !($fsiBus->{'slave'}->{'target'}->{'name'} eq "pu") && !($fsiBus->{'slave'}->{'target'}->{'name'} eq "memb") ) { next; } push @Fsis, [ #TYPE :: 'fsp master','hub master','cascaded master' $fsiBus->{'master'}->{'type'}, #LINK :: coming out of master $fsiBus->{'master'}->{'link'}, #TARGET :: Slave chip "n$fsiBus->{slave}->{target}->{node}:" . "p$fsiBus->{slave}->{target}->{position}", #MASTERNODE :: Master chip node "$fsiBus->{master}->{target}->{node}", #MASTERPOS :: Master chip position "$fsiBus->{master}->{target}->{position}", #TARGET_TYPE :: Slave chip type 'pu','memb' $fsiBus->{'slave'}->{'target'}->{'name'}, #SLAVE_PORT :: mproc->'fsi_slave0',altmproc->'fsi_slave1' $fsiBus->{'slave'}->{'unit-id'} ]; #print "\nTARGET=$Fsis[$#Fsis][FSI_TARGET_FIELD]\n"; #print "TYPE=$Fsis[$#Fsis][FSI_TYPE_FIELD]\n"; #print "LINK=$Fsis[$#Fsis][FSI_LINK_FIELD]\n"; #print "MASTERNODE=$Fsis[$#Fsis][FSI_MASTERNODE_FIELD]\n"; #print "MASTERPOS=$Fsis[$#Fsis][FSI_MASTERPOS_FIELD]\n"; #print "TARGET_TYPE=$Fsis[$#Fsis][FSI_TARGET_TYPE_FIELD]\n"; #print "SLAVE_PORT=$Fsis[$#Fsis][FSI_SLAVE_PORT_FIELD]\n"; } #print "Fsis = $#Fsis\n"; #------------------------------------------------------------------------------ # Process the psi-busses MRW file #------------------------------------------------------------------------------ my $psi_busses_file = open_mrw_file($mrwdir, "${sysname}-psi-busses.xml"); our $psiBus = parse_xml_file($psi_busses_file, forcearray=>['psi-bus']); # Capture all PSI connections into the @hbPSIs array use constant HB_PSI_MASTER_CHIP_POSITION_FIELD => 0; use constant HB_PSI_MASTER_CHIP_UNIT_FIELD => 1; use constant HB_PSI_PROC_NODE_FIELD => 2; use constant HB_PSI_PROC_POS_FIELD => 3; my @hbPSIs; foreach my $i (@{$psiBus->{'psi-bus'}}) { push @hbPSIs, [ $i->{fsp}->{'psi-unit'}->{target}->{position}, $i->{fsp}->{'psi-unit'}->{target}->{chipUnit}, $i->{processor}->{target}->{node}, $i->{processor}->{target}->{position}, ]; } #------------------------------------------------------------------------------ # Process the memory-busses MRW file #------------------------------------------------------------------------------ my $memory_busses_file = open_mrw_file($mrwdir, "${sysname}-memory-busses.xml"); my $memBus = parse_xml_file($memory_busses_file); # Capture all memory buses info into the @Membuses array use constant MCS_TARGET_FIELD => 0; use constant CENTAUR_TARGET_FIELD => 1; use constant DIMM_TARGET_FIELD => 2; use constant DIMM_PATH_FIELD => 3; use constant BUS_NODE_FIELD => 4; use constant BUS_POS_FIELD => 5; use constant BUS_ORDINAL_FIELD => 6; use constant DIMM_POS_FIELD => 7; use constant CDIMM_RID_NODE_MULTIPLIER => 32; my @Membuses; foreach my $i (@{$memBus->{'memory-bus'}}) { push @Membuses, [ "n$i->{mcs}->{target}->{node}:p$i->{mcs}->{target}->{position}:mcs" . $i->{mcs}->{target}->{chipUnit}, "n$i->{mba}->{target}->{node}:p$i->{mba}->{target}->{position}:mba" . $i->{mba}->{target}->{chipUnit}, "n$i->{dimm}->{target}->{node}:p$i->{dimm}->{target}->{position}", $i->{dimm}->{'instance-path'}, $i->{mcs}->{target}->{node}, $i->{mcs}->{target}->{position}, 0, $i->{dimm}->{'instance-path'} ]; } # Sort the memory busses, based on their Node, Pos & instance paths my @SMembuses = sort byDimmNodePos @Membuses; my $BOrdinal_ID = 0; # Increment the Ordinal ID in sequential order for dimms. for my $i ( 0 .. $#SMembuses ) { $SMembuses[$i] [BUS_ORDINAL_FIELD] = $BOrdinal_ID; $BOrdinal_ID += 1; } # Rewrite each DIMM instance path's DIMM instance to be indexed from 0 for my $i ( 0 .. $#SMembuses ) { $SMembuses[$i][DIMM_PATH_FIELD] =~ s/[0-9]*$/$i/; } # Generate @STargets array from the @Targets array to have the order as shown # belows. The rest of the codes assume that this order is in place # # pu # ex (one or more EX of pu before it) # core # mcs (one or more MCS of pu before it) # (Repeat for remaining pu) # memb # mba (to for membuf before it) # L4 # (Repeat for remaining membuf) # # Sort the target array based on Target Type,Node,Position and Chip-Unit. my @SortedTargets = sort byTargetTypeNodePosChipunit @Targets; my $Type = $SortedTargets[0][NAME_FIELD]; my $ordinal_ID = 0; # Increment the Ordinal ID in sequential order for same family Type. for my $i ( 0 .. $#SortedTargets ) { if($SortedTargets[$i][NAME_FIELD] ne $Type) { $ordinal_ID = 0; } $SortedTargets[$i] [ORDINAL_FIELD] = $ordinal_ID; $Type = $SortedTargets[$i][NAME_FIELD]; $ordinal_ID += 1; } my @fields; my @STargets; for my $i ( 0 .. $#SortedTargets ) { if ($SortedTargets[$i][NAME_FIELD] eq "pu") { for my $k ( 0 .. PLUG_POS ) { $fields[$k] = $SortedTargets[$i][$k]; } push @STargets, [ @fields ]; my $node = $SortedTargets[$i][NODE_FIELD]; my $position = $SortedTargets[$i][POS_FIELD]; for my $j ( 0 .. $#SortedTargets ) { if (($SortedTargets[$j][NAME_FIELD] eq "ex") && ($SortedTargets[$j][NODE_FIELD] eq $node) && ($SortedTargets[$j][POS_FIELD] eq $position)) { for my $k ( 0 .. PLUG_POS ) { $fields[$k] = $SortedTargets[$j][$k]; } push @STargets, [ @fields ]; } } for my $j ( 0 .. $#SortedTargets ) { if (($SortedTargets[$j][NAME_FIELD] eq "core") && ($SortedTargets[$j][NODE_FIELD] eq $node) && ($SortedTargets[$j][POS_FIELD] eq $position)) { for my $k ( 0 .. PLUG_POS ) { $fields[$k] = $SortedTargets[$j][$k]; } push @STargets, [ @fields ]; } } for my $j ( 0 .. $#SortedTargets ) { if (($SortedTargets[$j][NAME_FIELD] eq "mcs") && ($SortedTargets[$j][NODE_FIELD] eq $node) && ($SortedTargets[$j][POS_FIELD] eq $position)) { for my $k ( 0 .. PLUG_POS ) { $fields[$k] = $SortedTargets[$j][$k]; } push @STargets, [ @fields ]; } } } } for my $i ( 0 .. $#SortedTargets ) { if ($SortedTargets[$i][NAME_FIELD] eq "memb") { for my $k ( 0 .. PLUG_POS ) { $fields[$k] = $SortedTargets[$i][$k]; } push @STargets, [ @fields ]; my $node = $SortedTargets[$i][NODE_FIELD]; my $position = $SortedTargets[$i][POS_FIELD]; for my $j ( 0 .. $#SortedTargets ) { if (($SortedTargets[$j][NAME_FIELD] eq "mba") && ($SortedTargets[$j][NODE_FIELD] eq $node) && ($SortedTargets[$j][POS_FIELD] eq $position)) { for my $k ( 0 .. PLUG_POS ) { $fields[$k] = $SortedTargets[$j][$k]; } push @STargets, [ @fields ]; } } for my $p ( 0 .. $#SortedTargets ) { if (($SortedTargets[$p][NAME_FIELD] eq "L4") && ($SortedTargets[$p][NODE_FIELD] eq $node) && ($SortedTargets[$p][POS_FIELD] eq $position)) { for my $q ( 0 .. PLUG_POS ) { $fields[$q] = $SortedTargets[$p][$q]; } push @STargets, [ @fields ]; } } } } # Finally, generate the xml file. print "<!-- Source path(s) = $mrwdir -->\n"; print "<attributes>\n"; # First, generate system target (always sys0) my $sys = 0; generate_sys(); my $node = 0; my @mprocs; my $altMproc = 0; my $fru_id = 0; my @fru_paths; my $hasProc = 0; my $hash_ax_buses; my $axBusesHuidInit = 0; for (my $curnode = 0; $curnode <= $MAXNODE; $curnode++) { $node = $curnode; # find master proc of this node for my $i ( 0 .. $#Fsis ) { my $nodeId = lc($Fsis[$i][FSI_TARGET_FIELD]); $nodeId =~ s/.*n(.*):.*$/$1/; if ((lc($Fsis[$i][FSI_TYPE_FIELD]) eq "fsp master") && (($Fsis[$i][FSI_TARGET_TYPE_FIELD]) eq "pu") && ($nodeId eq $node)) { push @mprocs, $Fsis[$i][FSI_TARGET_FIELD]; #print "Mproc = $Fsis[$i][FSI_TARGET_FIELD]\n"; } } # Second, generate system node generate_system_node(); # Third, generate the FSP chip(s) foreach my $fsp ( keys %FSPs ) { if( $FSPs{$fsp}{node} eq $node ) { my $fspChipHashRef = (\%FSPs)->{$fsp}; do_plugin('fsp_chip', $fspChipHashRef); } } # Node has no master processor, maybe it is just a control node? if ($#mprocs < 0) { next; } #preCalculate HUID for A-Bus if($axBusesHuidInit == 0) { $axBusesHuidInit = 1; for (my $my_curnode = 0; $my_curnode <= $MAXNODE; $my_curnode++) { for (my $do_core = 0, my $i = 0; $i <= $#STargets; $i++) { if ($STargets[$i][NODE_FIELD] != $my_curnode) { next; } if ($STargets[$i][NAME_FIELD] eq "mcs") { my $proc = $STargets[$i][POS_FIELD]; if (($STargets[$i+1][NAME_FIELD] eq "pu") || ($STargets[$i+1][NAME_FIELD] eq "memb")) { preCalculateAxBusesHUIDs($my_curnode, $proc, "A"); preCalculateAxBusesHUIDs($my_curnode, $proc, "X"); } } } } } # Fourth, generate the proc, occ, ex-chiplet, mcs-chiplet # unit-tp (if on fsp), pcie bus and A/X-bus. my $ex_count = 0; my $ex_core_count = 0; my $mcs_count = 0; my $proc_ordinal_id =0; #my $fru_id = 0; #my @fru_paths; my $hwTopology =0; for (my $do_core = 0, my $i = 0; $i <= $#STargets; $i++) { if ($STargets[$i][NODE_FIELD] != $node) { next; } my $ipath = $STargets[$i][PATH_FIELD]; if ($STargets[$i][NAME_FIELD] eq "pu") { my $fru_found = 0; my $fru_path = $STargets[$i][FRU_PATH]; my $proc = $STargets[$i][POS_FIELD]; $proc_ordinal_id = $STargets[$i][ORDINAL_FIELD]; use constant FRU_PATHS => 0; use constant FRU_ID => 1; $hwTopology = $STargets[$i][NODE_FIELD] << 12; $fru_path =~ m/.*-([0-9]*)$/; $hwTopology |= $1 <<8; $ipath =~ m/.*-([0-9]*)$/; $hwTopology |= $1 <<4; my $lognode; my $logid; for (my $j = 0; $j <= $#chipIDs; $j++) { if ($chipIDs[$j][CHIP_ID_PATH] eq $ipath) { $lognode = $chipIDs[$j][CHIP_ID_NODE]; $logid = $chipIDs[$j][CHIP_ID_POS]; last; } } if($#fru_paths < 0) { $fru_id = 0; push @fru_paths, [ $fru_path, $fru_id ]; } else { for (my $k = 0; $k <= $#fru_paths; $k++) { if ( $fru_paths[$k][FRU_PATHS] eq $fru_path) { $fru_id = $fru_paths[$k][FRU_ID]; $fru_found = 1; last; } } if ($fru_found == 0) { $fru_id = $#fru_paths + 1; push @fru_paths, [ $fru_path, $fru_id ]; } } my @fsi; for (my $j = 0; $j <= $#Fsis; $j++) { if (($Fsis[$j][FSI_TARGET_FIELD] eq "n${node}:p$proc") && ($Fsis[$j][FSI_TARGET_TYPE_FIELD] eq "pu") && (lc($Fsis[$j][FSI_MASTERPOS_FIELD]) eq "0") && (lc($Fsis[$j][FSI_TYPE_FIELD]) eq "hub master") ) { @fsi = @{@Fsis[$j]}; last; } } my @altfsi; for (my $j = 0; $j <= $#Fsis; $j++) { if (($Fsis[$j][FSI_TARGET_FIELD] eq "n${node}:p$proc") && ($Fsis[$j][FSI_TARGET_TYPE_FIELD] eq "pu") && (lc($Fsis[$j][FSI_MASTERPOS_FIELD]) eq "1") && (lc($Fsis[$j][FSI_TYPE_FIELD]) eq "hub master") ) { @altfsi = @{@Fsis[$j]}; last; } } my $is_master = 0; foreach my $m (@mprocs) { if ($m eq "n${node}:p$proc") { $is_master = 1; } } generate_proc($proc, $is_master, $ipath, $lognode, $logid, $proc_ordinal_id, \@fsi, \@altfsi, $fru_id, $hwTopology); # call to do any fsp per-proc targets (ie, occ, psi) do_plugin('fsp_proc_targets', $proc, $i, $proc_ordinal_id, $STargets[$i][NODE_FIELD], $STargets[$i][POS_FIELD]); } elsif ($STargets[$i][NAME_FIELD] eq "ex") { my $proc = $STargets[$i][POS_FIELD]; my $ex = $STargets[$i][UNIT_FIELD]; if ($ex_count == 0) { print "\n<!-- $SYSNAME n${node}p$proc EX units -->\n"; } generate_ex($proc, $ex, $STargets[$i][ORDINAL_FIELD], $ipath); $ex_count++; if ($STargets[$i+1][NAME_FIELD] eq "core") { $ex_count = 0; } } elsif ($STargets[$i][NAME_FIELD] eq "core") { my $proc = $STargets[$i][POS_FIELD]; my $ex = $STargets[$i][UNIT_FIELD]; if ($ex_core_count == 0) { print "\n<!-- $SYSNAME n${node}p$proc core units -->\n"; } generate_ex_core($proc,$ex,$STargets[$i][ORDINAL_FIELD], $STargets[$i][PATH_FIELD]); $ex_core_count++; if ($STargets[$i+1][NAME_FIELD] eq "mcs") { $ex_core_count = 0; } } elsif ($STargets[$i][NAME_FIELD] eq "mcs") { my $proc = $STargets[$i][POS_FIELD]; my $mcs = $STargets[$i][UNIT_FIELD]; if ($mcs_count == 0) { print "\n<!-- $SYSNAME n${node}p$proc MCS units -->\n"; } generate_mcs($proc,$mcs, $STargets[$i][ORDINAL_FIELD], $ipath); $mcs_count++; if (($STargets[$i+1][NAME_FIELD] eq "pu") || ($STargets[$i+1][NAME_FIELD] eq "memb")) { $mcs_count = 0; generate_pcies($proc,$proc_ordinal_id); generate_ax_buses($proc, "A",$proc_ordinal_id); generate_ax_buses($proc, "X",$proc_ordinal_id); generate_nx($proc,$proc_ordinal_id,$node); generate_pore($proc,$proc_ordinal_id,$node); generate_capp($proc,$proc_ordinal_id,$node); } } } # Fifth, generate the Centaur, L4, and MBA my $memb; my $membMcs; my $mba_count = 0; for my $i ( 0 .. $#STargets ) { if ($STargets[$i][NODE_FIELD] != $node) { next; } my $ipath = $STargets[$i][PATH_FIELD]; if ($STargets[$i][NAME_FIELD] eq "memb") { $memb = $STargets[$i][POS_FIELD]; my $centaur = "n${node}:p${memb}"; my $found = 0; my $cfsi; for my $j ( 0 .. $#Membuses ) { my $mba = $Membuses[$j][CENTAUR_TARGET_FIELD]; $mba =~ s/(.*):mba.*$/$1/; if ($mba eq $centaur) { $membMcs = $Membuses[$j][MCS_TARGET_FIELD]; $found = 1; last; } } if ($found == 0) { die "ERROR. Can't locate Centaur from memory bus table\n"; } my @fsi; for (my $j = 0; $j <= $#Fsis; $j++) { if (($Fsis[$j][FSI_TARGET_FIELD] eq "n${node}:p${memb}") && ($Fsis[$j][FSI_TARGET_TYPE_FIELD] eq "memb") && (lc($Fsis[$j][FSI_SLAVE_PORT_FIELD]) eq "fsi_slave0") && (lc($Fsis[$j][FSI_TYPE_FIELD]) eq "cascaded master") ) { @fsi = @{@Fsis[$j]}; last; } } my @altfsi; for (my $j = 0; $j <= $#Fsis; $j++) { if (($Fsis[$j][FSI_TARGET_FIELD] eq "n${node}:p${memb}") && ($Fsis[$j][FSI_TARGET_TYPE_FIELD] eq "memb") && (lc($Fsis[$j][FSI_SLAVE_PORT_FIELD]) eq "fsi_slave1") && (lc($Fsis[$j][FSI_TYPE_FIELD]) eq "cascaded master") ) { @altfsi = @{@Fsis[$j]}; last; } } my $relativeCentaurRid = $STargets[$i][PLUG_POS] + (CDIMM_RID_NODE_MULTIPLIER * $STargets[$i][NODE_FIELD]); generate_centaur( $memb, $membMcs, \@fsi, \@altfsi, $ipath, $STargets[$i][ORDINAL_FIELD],$relativeCentaurRid, $ipath, $membufVrmUuidHash{"n${node}:p${memb}"}); } elsif ($STargets[$i][NAME_FIELD] eq "mba") { if ($mba_count == 0) { print "\n"; print "<!-- $SYSNAME Centaur MBAs affiliated with membuf$memb -->"; print "\n"; } my $mba = $STargets[$i][UNIT_FIELD]; generate_mba( $memb, $membMcs, $mba, $STargets[$i][ORDINAL_FIELD], $ipath); $mba_count += 1; if ($mba_count == 2) { $mba_count = 0; print "\n<!-- $SYSNAME Centaur n${node}p${memb} : end -->\n" } } elsif ($STargets[$i][NAME_FIELD] eq "L4") { print "\n"; print "<!-- $SYSNAME Centaur L4 affiliated with membuf$memb -->"; print "\n"; my $l4 = $STargets[$i][UNIT_FIELD]; generate_l4( $memb, $membMcs, $l4, $STargets[$i][ORDINAL_FIELD], $ipath ); print "\n<!-- $SYSNAME Centaur n${node}p${l4} : end -->\n" } } # Sixth, generate DIMM targets print "\n<!-- $SYSNAME Centaur DIMMs -->\n"; for my $i ( 0 .. $#SMembuses ) { if ($SMembuses[$i][BUS_NODE_FIELD] != $node) { next; } my $ipath = $SMembuses[$i][DIMM_PATH_FIELD]; my $proc = $SMembuses[$i][MCS_TARGET_FIELD]; my $mcs = $proc; $proc =~ s/.*:p(.*):.*/$1/; $mcs =~ s/.*mcs(.*)/$1/; my $ctaur = $SMembuses[$i][CENTAUR_TARGET_FIELD]; my $mba = $ctaur; $ctaur =~ s/.*:p(.*):mba.*$/$1/; $mba =~ s/.*:mba(.*)$/$1/; my $pos = $SMembuses[$i][DIMM_TARGET_FIELD]; $pos =~ s/.*:p(.*)/$1/; my $dimm = $SMembuses[$i][DIMM_PATH_FIELD]; $dimm =~ s/.*dimm-(.*)/$1/; my $relativeDimmRid = $dimm; my $dimmPos = $SMembuses[$i][DIMM_POS_FIELD]; $dimmPos =~ s/.*dimm-(.*)/$1/; my $relativePos = $dimmPos; print "\n<!-- C-DIMM n${node}:p${pos} -->\n"; for my $id ( 0 .. 7 ) { my $dimmid = $dimm; $dimmid <<= 3; $dimmid |= $id; $dimmid = sprintf ("%d", $dimmid); generate_dimm( $proc, $mcs, $ctaur, $pos, $dimmid, $id, ($SMembuses[$i][BUS_ORDINAL_FIELD]*8)+$id, $relativeDimmRid, $relativePos, $ipath); } } # call to do pnor attributes do_plugin('all_pnors', $node); # call to do refclk attributes do_plugin('all_refclk'); } print "\n</attributes>\n"; # All done! #close ($outFH); exit 0; ########## Subroutines ############## ################################################################################ # utility function used to preCalculate the AX Buses HUIDs ################################################################################ sub preCalculateAxBusesHUIDs { my ($my_node, $proc, $type) = @_; my ($minbus, $maxbus, $numperchip, $typenum, $type) = getBusInfo($type, $CHIPNAME); for my $i ( $minbus .. $maxbus ) { my $uidstr = sprintf( "0x%02X%02X%04X", ${my_node}, $typenum, $proc*$numperchip + $i); my $phys_path = "physical:sys-$sys/node-$my_node/proc-$proc/${type}bus-$i"; $hash_ax_buses->{$phys_path} = $uidstr; #print STDOUT "Phys Path = $phys_path, HUID = $uidstr\n"; } } ################################################################################ # utility function used to call plugins. if none exists, call is skipped. ################################################################################ sub do_plugin { my $step = shift; if (exists($hwsvmrw_plugins{$step})) { $hwsvmrw_plugins{$step}(@_); } elsif ($DEBUG && ($build eq "fsp")) { print STDERR "build is $build but no plugin for $step\n"; } } ################################################################################ # Compares two MRW Targets based on the Type,Node,Position & Chip-Unit # ################################################################################ sub byTargetTypeNodePosChipunit ($$) { # Operates on two Targets, based on the following parameters Targets will # get sorted, # 1.Type of the Target.Ex; pu , ex , mcs ,mba etc. # 2.Node of the Target.Node instance number, integer 0,1,2 etc. # 3.Position of the Target, integer 0,1,2 etc. # 4.ChipUnit of the Target , integer 0,1,2 etc. # Note the above order is sequential & comparison is made in the same order. #Assume always $lhsInstance < $rhsInstance, will reduce redundant coding. my $retVal = -1; # Get just the instance path for each supplied memory bus my $lhsInstance_Type = $_[0][NAME_FIELD]; my $rhsInstance_Type = $_[1][NAME_FIELD]; if($lhsInstance_Type eq $rhsInstance_Type) { my $lhsInstance_Node = $_[0][NODE_FIELD]; my $rhsInstance_Node = $_[1][NODE_FIELD]; if(int($lhsInstance_Node) eq int($rhsInstance_Node)) { my $lhsInstance_Pos = $_[0][POS_FIELD]; my $rhsInstance_Pos = $_[1][POS_FIELD]; if(int($lhsInstance_Pos) eq int($rhsInstance_Pos)) { my $lhsInstance_ChipUnit = $_[0][UNIT_FIELD]; my $rhsInstance_ChipUnit = $_[1][UNIT_FIELD]; if(int($lhsInstance_ChipUnit) eq int($rhsInstance_ChipUnit)) { die "ERROR: Duplicate Targets: 2 Targets with same \ TYPE: $lhsInstance_Type NODE: $lhsInstance_Node \ POSITION: $lhsInstance_Pos \ & CHIP-UNIT: $lhsInstance_ChipUnit\n"; } elsif(int($lhsInstance_ChipUnit) > int($rhsInstance_ChipUnit)) { $retVal = 1; } } elsif(int($lhsInstance_Pos) > int($rhsInstance_Pos)) { $retVal = 1; } } elsif(int($lhsInstance_Node) > int($rhsInstance_Node)) { $retVal = 1; } } elsif($lhsInstance_Type gt $rhsInstance_Type) { $retVal = 1; } return $retVal; } ################################################################################ # Compares two MRW DIMMs based on the Node,Position & DIMM instance # ################################################################################ sub byDimmNodePos($$) { # Operates on two Targets, based on the following parameters Targets will # get sorted, # 1.Node of the Target.Node instance number, integer 0,1,2 etc. # 2.Position of the Target, integer 0,1,2 etc. # 3.On two DIMM instance paths, each in the form of: # assembly-0/shilin-0/dimm-X # # Assumes that "X is always a decimal number, and that every DIMM in the # system has a unique value of "X", including for multi-node systems and for # systems whose DIMMs are contained on different parts of the system # topology # # Note, in the path example above, the parts leading up to the dimm-X could # be arbitrarily deep and have different types/instance values # # Note the above order is sequential & comparison is made in the same order. #Assume always $lhsInstance < $rhsInstance, will reduce redundant coding. my $retVal = -1; my $lhsInstance_node = $_[0][BUS_NODE_FIELD]; my $rhsInstance_node = $_[1][BUS_NODE_FIELD]; if(int($lhsInstance_node) eq int($rhsInstance_node)) { my $lhsInstance_pos = $_[0][BUS_POS_FIELD]; my $rhsInstance_pos = $_[1][BUS_POS_FIELD]; if(int($lhsInstance_pos) eq int($rhsInstance_pos)) { # Get just the instance path for each supplied memory bus my $lhsInstance = $_[0][DIMM_PATH_FIELD]; my $rhsInstance = $_[1][DIMM_PATH_FIELD]; # Replace each with just its DIMM instance value (a string) $lhsInstance =~ s/.*-([0-9]*)$/$1/; $rhsInstance =~ s/.*-([0-9]*)$/$1/; if(int($lhsInstance) eq int($rhsInstance)) { die "ERROR: Duplicate Dimms: 2 Dimms with same TYPE, \ NODE: $lhsInstance_node POSITION: $lhsInstance_pos & \ PATH FIELD: $lhsInstance\n"; } elsif(int($lhsInstance) > int($rhsInstance)) { $retVal = 1; } } elsif(int($lhsInstance_pos) > int($rhsInstance_pos)) { $retVal = 1; } } elsif(int($lhsInstance_node) > int($rhsInstance_node)) { $retVal = 1; } return $retVal; } ################################################################################ # Compares two MRW DIMM instance paths based only on the DIMM instance # ################################################################################ sub byDimmInstancePath ($$) { # Operates on two DIMM instance paths, each in the form of: # assembly-0/shilin-0/dimm-X # # Assumes that "X is always a decimal number, and that every DIMM in the # system has a unique value of "X", including for multi-node systems and for # systems whose DIMMs are contained on different parts of the system # topology # # Note, in the path example above, the parts leading up to the dimm-X could # be arbitrarily deep and have different types/instance values # Get just the instance path for each supplied memory bus my $lhsInstance = $_[0][DIMM_PATH_FIELD]; my $rhsInstance = $_[1][DIMM_PATH_FIELD]; # Replace each with just its DIMM instance value (a string) $lhsInstance =~ s/.*-([0-9]*)$/$1/; $rhsInstance =~ s/.*-([0-9]*)$/$1/; # Convert each DIMM instance value string to int, and return comparison return int($lhsInstance) <=> int($rhsInstance); } ################################################################################ # Compares two arrays based on chip node and position ################################################################################ sub byNodePos($$) { my $retVal = -1; my $lhsInstance_node = $_[0][CHIP_NODE_INDEX]; my $rhsInstance_node = $_[1][CHIP_NODE_INDEX]; if(int($lhsInstance_node) eq int($rhsInstance_node)) { my $lhsInstance_pos = $_[0][CHIP_POS_INDEX]; my $rhsInstance_pos = $_[1][CHIP_POS_INDEX]; if(int($lhsInstance_pos) eq int($rhsInstance_pos)) { die "ERROR: Duplicate chip positions: 2 chip with same node and position, \ NODE: $lhsInstance_node POSITION: $lhsInstance_pos\n"; } elsif(int($lhsInstance_pos) > int($rhsInstance_pos)) { $retVal = 1; } } elsif(int($lhsInstance_node) > int($rhsInstance_node)) { $retVal = 1; } return $retVal; } sub generate_sys { my $plat = 0; if ($build eq "fsp") { $plat = 2; } elsif ($build eq "hb") { $plat = 1; } print " <!-- $SYSNAME System with new values--> <targetInstance> <id>sys$sys</id> <type>sys-sys-power8</type> <attribute> <id>PHYS_PATH</id> <default>physical:sys-$sys</default> </attribute> <attribute> <id>AFFINITY_PATH</id> <default>affinity:sys-$sys</default> </attribute> <compileAttribute> <id>INSTANCE_PATH</id> <default>instance:sys-$sys</default> </compileAttribute> <attribute> <id>EXECUTION_PLATFORM</id> <default>$plat</default> </attribute>\n"; print " <!-- System Attributes from MRW -->\n"; addSysAttrs(); print " <!-- End System Attributes from MRW -->\n"; print " <attribute> <id>SP_FUNCTIONS</id> <default> <field><id>baseServices</id><value>1</value></field> <field><id>fsiSlaveInit</id><value>1</value></field> <field><id>mailboxEnabled</id><value>1</value></field> <field><id>fsiMasterInit</id><value>1</value></field> <field><id>hardwareChangeDetection</id><value>1</value></field> <field><id>powerLineDisturbance</id><value>1</value></field> <field><id>reserved</id><value>0</value></field> </default> </attribute> <attribute> <id>HB_SETTINGS</id> <default> <field><id>traceContinuous</id><value>0</value></field> <field><id>traceScanDebug</id><value>0</value></field> <field><id>reserved</id><value>0</value></field> </default> </attribute> <attribute> <id>PAYLOAD_KIND</id> <default>PHYP</default> </attribute>"; generate_max_config(); # HDAT drawer number (physical node) to # HostBoot Instance number (logical node) map # Index is the hdat drawer number, value is the HB instance number # Only the max drawer system needs to be represented. if ($sysname =~ /brazos/) { print " <!-- correlate HDAT drawer number to Hostboot Instance number --> <attribute><id>FABRIC_TO_PHYSICAL_NODE_MAP</id> <default>0,1,2,3,255,255,255,255</default> </attribute> "; } else # single drawer { print " <!-- correlate HDAT drawer number to Hostboot Instance number --> <attribute><id>FABRIC_TO_PHYSICAL_NODE_MAP</id> <default>0,255,255,255,255,255,255,255</default> </attribute> "; } # call to do any fsp per-sys attributes do_plugin('fsp_sys', $sys, $sysname, 0); print " </targetInstance> "; } sub generate_max_config { my $maxMcs_Per_System = 0; my $maxChiplets_Per_Proc = 0; my $maxProcChip_Per_Node =0; my $maxEx_Per_Proc =0; my $maxDimm_Per_MbaPort =0; my $maxMbaPort_Per_Mba =0; my $maxMba_Per_MemBuf =0; # MBA Ports Per MBA is 2 in P8 and is hard coded here use constant MBA_PORTS_PER_MBA => 2; # MAX Chiplets Per Proc is 32 and is hard coded here use constant CHIPLETS_PER_PROC => 32; # MAX Mba Per MemBuf is 2 and is hard coded here # PNEW_TODO to change if P9 different use constant MAX_MBA_PER_MEMBUF => 2; # MAX Dimms Per MBA PORT is 2 and is hard coded here # PNEW_TODO to change if P9 different use constant MAX_DIMMS_PER_MBAPORT => 2; for (my $i = 0; $i < $#STargets; $i++) { if ($STargets[$i][NAME_FIELD] eq "pu") { if ($node == 0) { $maxProcChip_Per_Node += 1; } } elsif ($STargets[$i][NAME_FIELD] eq "ex") { my $proc = $STargets[$i][POS_FIELD]; if (($proc == 0) && ($node == 0)) { $maxEx_Per_Proc += 1; } } elsif ($STargets[$i][NAME_FIELD] eq "mcs") { $maxMcs_Per_System += 1; } } # loading the hard coded value $maxMbaPort_Per_Mba = MBA_PORTS_PER_MBA; # loading the hard coded value $maxChiplets_Per_Proc = CHIPLETS_PER_PROC; # loading the hard coded value $maxMba_Per_MemBuf = MAX_MBA_PER_MEMBUF; # loading the hard coded value $maxDimm_Per_MbaPort = MAX_DIMMS_PER_MBAPORT; print " <attribute> <id>MAX_PROC_CHIPS_PER_NODE</id> <default>$maxProcChip_Per_Node</default> </attribute> <attribute> <id>MAX_EXS_PER_PROC_CHIP</id> <default>$maxEx_Per_Proc</default> </attribute> <attribute> <id>MAX_MBAS_PER_MEMBUF_CHIP</id> <default>$maxMba_Per_MemBuf</default> </attribute> <attribute> <id>MAX_MBA_PORTS_PER_MBA</id> <default>$maxMbaPort_Per_Mba</default> </attribute> <attribute> <id>MAX_DIMMS_PER_MBA_PORT</id> <default>$maxDimm_Per_MbaPort</default> </attribute> <attribute> <id>MAX_CHIPLETS_PER_PROC</id> <default>$maxChiplets_Per_Proc</default> </attribute> <attribute> <id>MAX_MCS_PER_SYSTEM</id> <default>$maxMcs_Per_System</default> </attribute>"; } my $computeNodeInit = 0; my %computeNodeList = (); sub generate_compute_node_ipath { my $location_codes_file = open_mrw_file($::mrwdir, "${sysname}-location-codes.xml"); my $nodeTargets = parse_xml_file($location_codes_file); #get the node (compute) ipath details foreach my $Target (@{$nodeTargets->{'location-code-entry'}}) { if($Target->{'assembly-type'} eq "compute") { my $ipath = $Target->{'instance-path'}; my $assembly = $Target->{'assembly-type'}; my $position = $Target->{position}; $computeNodeList{$position} = { 'position' => $position, 'assembly' => $assembly, 'instancePath' => $ipath, } } } } sub generate_system_node { # Get the node ipath info if ($computeNodeInit == 0) { generate_compute_node_ipath; $computeNodeInit = 1; } # Brazos node4 is the fsp node and we'll let the fsp # MRW parser handle that. if( !( ($sysname =~ /brazos/) && ($node == $MAXNODE) ) ) { print " <!-- $SYSNAME System node $node --> <targetInstance> <id>sys${sys}node${node}</id> <type>enc-node-power8</type> <attribute><id>HUID</id><default>0x0${node}020000</default></attribute> <attribute> <id>PHYS_PATH</id> <default>physical:sys-$sys/node-$node</default> </attribute> <attribute> <id>AFFINITY_PATH</id> <default>affinity:sys-$sys/node-$node</default> </attribute> <compileAttribute> <id>INSTANCE_PATH</id> <default>instance:$computeNodeList{$node}->{'instancePath'}</default> </compileAttribute>"; # add fsp extensions do_plugin('fsp_node_add_extensions', $node); print " </targetInstance> "; } else { # create fsp control node do_plugin('fsp_control_node', $node); } # call to do any fsp per-system_node targets do_plugin('fsp_system_node_targets', $node); } sub generate_proc { my ($proc, $is_master, $ipath, $lognode, $logid, $ordinalId, $fsiA, $altfsiA, $fruid, $hwTopology) = @_; my @fsi = @{$fsiA}; my @altfsi = @{$altfsiA}; my $uidstr = sprintf("0x%02X05%04X",${node},${proc}); my $vpdnum = ${proc}; my $position = ${proc}; my $scomFspApath = $devpath->{chip}->{$ipath}->{'scom-path-a'}; my $scanFspApath = $devpath->{chip}->{$ipath}->{'scan-path-a'}; my $scomFspAsize = length($scomFspApath) + 1; my $scanFspAsize = length($scanFspApath) + 1; my $scomFspBpath = ""; if (ref($devpath->{chip}->{$ipath}->{'scom-path-b'}) ne "HASH") { $scomFspBpath = $devpath->{chip}->{$ipath}->{'scom-path-b'}; } my $scanFspBpath = ""; if (ref($devpath->{chip}->{$ipath}->{'scan-path-b'}) ne "HASH") { $scanFspBpath = $devpath->{chip}->{$ipath}->{'scan-path-b'}; } my $scomFspBsize = length($scomFspBpath) + 1; my $scanFspBsize = length($scanFspBpath) + 1; my $mboxFspApath = ""; my $mboxFspAsize = 0; my $mboxFspBpath = ""; my $mboxFspBsize = 0; if (exists $devpath->{chip}->{$ipath}->{'mailbox-path-a'}) { $mboxFspApath = $devpath->{chip}->{$ipath}->{'mailbox-path-a'}; $mboxFspAsize = length($mboxFspApath) + 1; } if (exists $devpath->{chip}->{$ipath}->{'mailbox-path-b'}) { $mboxFspBpath = $devpath->{chip}->{$ipath}->{'mailbox-path-b'}; $mboxFspBsize = length($mboxFspBpath) + 1; } my $psichip = 0; my $psilink = 0; for my $psi ( 0 .. $#hbPSIs ) { if(($node eq $hbPSIs[$psi][HB_PSI_PROC_NODE_FIELD]) && ($proc eq $hbPSIs[$psi][HB_PSI_PROC_POS_FIELD] )) { $psichip = $hbPSIs[$psi][HB_PSI_MASTER_CHIP_POSITION_FIELD]; $psilink = $hbPSIs[$psi][HB_PSI_MASTER_CHIP_UNIT_FIELD]; last; } } #MURANO=DCM installed, VENICE=SCM my $dcm_installed = 0; if($CHIPNAME eq "murano") { $dcm_installed = 1; } my $mruData = get_mruid($ipath); print " <!-- $SYSNAME n${node}p${proc} processor chip --> <targetInstance> <id>sys${sys}node${node}proc${proc}</id> <type>chip-processor-$CHIPNAME</type> <attribute><id>HUID</id><default>${uidstr}</default></attribute> <attribute><id>POSITION</id><default>${position}</default></attribute> <attribute><id>SCOM_SWITCHES</id> <default> <field><id>useFsiScom</id><value>1</value></field> <field><id>useXscom</id><value>0</value></field> <field><id>useInbandScom</id><value>0</value></field> <field><id>reserved</id><value>0</value></field> </default> </attribute> <attribute> <id>PHYS_PATH</id> <default>physical:sys-$sys/node-$node/proc-$proc</default> </attribute> <attribute> <id>MRU_ID</id> <default>$mruData</default> </attribute> <attribute> <id>AFFINITY_PATH</id> <default>affinity:sys-$sys/node-$node/proc-$proc</default> </attribute> <compileAttribute> <id>INSTANCE_PATH</id> <default>instance:$ipath</default> </compileAttribute> <attribute> <id>FABRIC_NODE_ID</id> <default>$lognode</default> </attribute> <attribute> <id>FABRIC_CHIP_ID</id> <default>$logid</default> </attribute> <attribute> <id>FRU_ID</id> <default>$fruid</default> </attribute> <attribute><id>VPD_REC_NUM</id><default>$vpdnum</default></attribute> <attribute><id>PROC_DCM_INSTALLED</id> <default>$dcm_installed</default> </attribute>"; #For FSP-based systems, the default will always get overridden by the # the FSP code before it is used, based on which FSP is being used as # the primary. Therefore, the default is only relevant in the BMC # case where it is required since the value generated here will not # be updated before it is used by HB. ## Master value ## if( $is_master && ($proc == 0) ) { print " <attribute> <id>PROC_MASTER_TYPE</id> <default>ACTING_MASTER</default> </attribute>"; } elsif( $is_master ) { print " <attribute> <id>PROC_MASTER_TYPE</id> <default>MASTER_CANDIDATE</default> </attribute>"; } else { print " <attribute> <id>PROC_MASTER_TYPE</id> <default>NOT_MASTER</default> </attribute>"; } ## Setup FSI Attributes ## if( ($#fsi <= 0) && ($#altfsi <= 0) ) { print " <!-- No FSI connection --> <attribute> <id>FSI_MASTER_TYPE</id> <default>NO_MASTER</default> </attribute>"; } else { print " <!-- FSI connections --> <attribute> <id>FSI_MASTER_TYPE</id> <default>MFSI</default> </attribute>"; } # if a proc is sometimes the master then it # will have flipped ports my $flipport = 0; if( $is_master ) { $flipport = 1; } # these values are common for both fsi ports print " <attribute> <id>FSI_SLAVE_CASCADE</id> <default>0</default> </attribute> <attribute> <id>FSI_OPTION_FLAGS</id> <default> <field><id>flipPort</id><value>$flipport</value></field> <field><id>reserved</id><value>0</value></field> </default> </attribute>"; if( $#fsi <= 0 ) { print " <!-- FSI-A is not connected --> <attribute> <id>FSI_MASTER_CHIP</id> <default>physical:sys</default><!-- no A path --> </attribute> <attribute> <id>FSI_MASTER_PORT</id> <default>0xFF</default><!-- no A path --> </attribute>"; } else { my $mNode = $fsi[FSI_MASTERNODE_FIELD]; my $mPos = $fsi[FSI_MASTERPOS_FIELD]; my $link = $fsi[FSI_LINK_FIELD]; print " <!-- FSI-A is connected via node$mNode:proc$mPos:MFSI-$link --> <attribute> <id>FSI_MASTER_CHIP</id> <default>physical:sys-$sys/node-$mNode/proc-$mPos</default> </attribute> <attribute> <id>FSI_MASTER_PORT</id> <default>$link</default> </attribute>"; } if( $#altfsi <= 0 ) { print " <!-- FSI-B is not connected --> <attribute> <id>ALTFSI_MASTER_CHIP</id> <default>physical:sys</default><!-- no B path --> </attribute> <attribute> <id>ALTFSI_MASTER_PORT</id> <default>0xFF</default><!-- no B path --> </attribute>\n"; } else { my $mNode = $altfsi[FSI_MASTERNODE_FIELD]; my $mPos = $altfsi[FSI_MASTERPOS_FIELD]; my $link = $altfsi[FSI_LINK_FIELD]; print " <!-- FSI-B is connected via node$mNode:proc$mPos:MFSI-$link --> <attribute> <id>ALTFSI_MASTER_CHIP</id> <default>physical:sys-$sys/node-$mNode/proc-$mPos</default> </attribute> <attribute> <id>ALTFSI_MASTER_PORT</id> <default>$link</default> </attribute>\n"; } print " <!-- End FSI connections -->\n"; ## End FSI ## # add EEPROM attributes addEeproms($sys, $node, $proc); # fsp-specific proc attributes do_plugin('fsp_proc', $scomFspApath, $scomFspAsize, $scanFspApath, $scanFspAsize, $scomFspBpath, $scomFspBsize, $scanFspBpath, $scanFspBsize, $node, $proc, $fruid, $ipath, $hwTopology, $mboxFspApath, $mboxFspAsize, $mboxFspBpath, $mboxFspBsize, $ordinalId ); # Data from PHYP Memory Map print "\n"; print " <!-- Data from PHYP Memory Map -->\n"; # Calculate the FSP and PSI BRIGDE BASE ADDR my $fspBase = 0; my $psiBase = 0; foreach my $i (@{$psiBus->{'psi-bus'}}) { if (($i->{'processor'}->{target}->{position} eq $proc) && ($i->{'processor'}->{target}->{node} eq $node )) { $fspBase = 0x0003FFE000000000 + 0x400000000*$lognode + 0x100000000*$logid; $psiBase = 0x0003FFFE80000000 + 0x400000*$psichip + 0x100000*$psilink; last; } } # Starts at 1024TB - 128GB, 4GB per proc printf( " <attribute><id>FSP_BASE_ADDR</id>\n" ); printf( " <default>0x%016X</default>\n", $fspBase ); printf( " </attribute>\n" ); # Starts at 1024TB - 6GB, 1MB per link/proc printf( " <attribute><id>PSI_BRIDGE_BASE_ADDR</id>\n" ); printf( " <default>0x%016X</default>\n", $psiBase ); printf( " </attribute>\n" ); # Starts at 1024TB - 2GB, 1MB per proc printf( " <attribute><id>INTP_BASE_ADDR</id>\n" ); printf( " <default>0x%016X</default>\n", 0x0003FFFF80000000 + 0x400000*$lognode + 0x100000*$logid ); printf( " </attribute>\n" ); # Starts at 1024TB - 7GB, 1MB per PHB (=4MB per proc) printf( " <attribute><id>PHB_BASE_ADDRS</id>\n" ); printf( " <default>\n" ); printf( " 0x%016X,0x%016X,\n", 0x0003FFFE40000000 + 0x1000000*$lognode + 0x400000*$logid + 0x100000*0, 0x0003FFFE40000000 + 0x1000000*$lognode + 0x400000*$logid + 0x100000*1 ); printf( " 0x%016X,0x%016X\n", 0x0003FFFE40000000 + 0x1000000*$lognode + 0x400000*$logid + 0x100000*2, 0x0003FFFE40000000 + 0x1000000*$lognode + 0x400000*$logid + 0x100000*3 ); printf( " </default>\n" ); printf( " </attribute>\n" ); # Starts at 1024TB -0.5TB, 2GB per PHB (=8GB per proc) printf( " <attribute><id>PCI_BASE_ADDRS_32</id>\n" ); printf( " <default>\n" ); printf( " 0x%016X,0x%016X,\n", 0x0003FF8000000000 + 0x800000000*$lognode + 0x200000000*$logid + 0x80000000*0, 0x0003FF8000000000 + 0x800000000*$lognode + 0x200000000*$logid + 0x80000000*1 ); printf( " 0x%016X,0x%016X\n", 0x0003FF8000000000 + 0x800000000*$lognode + 0x200000000*$logid + 0x80000000*2, 0x0003FF8000000000 + 0x800000000*$lognode + 0x200000000*$logid + 0x80000000*3 ); printf( " </default>\n" ); printf( " </attribute>\n" ); # Starts at 976TB, 64GB per PHB (=256GB per proc) printf( " <attribute><id>PCI_BASE_ADDRS_64</id>\n" ); printf( " <default>\n" ); printf( " 0x%016X,0x%016X,\n", 0x0003D00000000000 + 0x10000000000*$lognode + 0x4000000000*$logid + 0x1000000000*0, 0x0003D00000000000 + 0x10000000000*$lognode + 0x4000000000*$logid + 0x1000000000*1 ); printf( " 0x%016X,0x%016X\n", 0x0003D00000000000 + 0x10000000000*$lognode + 0x4000000000*$logid + 0x1000000000*2, 0x0003D00000000000 + 0x10000000000*$lognode + 0x4000000000*$logid + 0x1000000000*3 ); printf( " </default>\n" ); printf( " </attribute>\n" ); # Starts at 1024TB - 3GB printf( " <attribute><id>RNG_BASE_ADDR</id>\n" ); printf( " <default>0x%016X</default>\n", 0x0003FFFF40000000 + 0x4000*$lognode + 0x1000*$logid ); printf( " </attribute>\n" ); # Starts at 992TB - 128GB per MCS/Centaur printf( " <attribute><id>IBSCOM_PROC_BASE_ADDR</id>\n" ); printf( " <default>0x%016X</default>\n", 0x0003E00000000000 + 0x40000000000*$lognode + 0x10000000000*$logid ); printf( " </attribute>\n" ); print " <!-- End PHYP Memory Map -->\n\n"; # end PHYP Memory Map print " <!-- PROC_PCIE_ attributes -->\n"; addProcPcieAttrs( $proc, $node ); print " <!-- End PROC_PCIE_ attributes -->\n"; print " <!-- The default value of the following three attributes are written by --> <!-- the FSP. They are included here because VBU/VPO uses faked PNOR. --> <attribute> <id>PROC_PCIE_IOP_CONFIG</id> <default>0</default> </attribute> <attribute> <id>PROC_PCIE_IOP_SWAP</id> <default>$pcie_list{$ipath}{0}{0}{'lane-swap'}, $pcie_list{$ipath}{1}{0}{'lane-swap'} </default> </attribute> <attribute> <id>PROC_PCIE_PHB_ACTIVE</id> <default>0</default> </attribute>\n"; if ((scalar @SortedPmChipAttr) == 0) { # Default the values. print " <!-- PM_ attributes (default values) -->\n"; print " <attribute>\n"; print " <id>PM_UNDERVOLTING_FRQ_MINIMUM</id>\n"; print " <default>0</default>\n"; print " </attribute>\n"; print " <attribute>\n"; print " <id>PM_UNDERVOLTING_FREQ_MAXIMUM</id>\n"; print " <default>0</default>\n"; print " </attribute>\n"; print " <attribute>\n"; print " <id>PM_SPIVID_PORT_ENABLE</id>\n"; if( $proc % 2 == 0 ) # proc0 of DCM { print " <default>0x4</default><!-- PORT0NONRED -->\n"; } else # proc1 of DCM { print " <default>0x0</default><!-- NONE -->\n"; } print " </attribute>\n"; print " <attribute>\n"; print " <id>PM_APSS_CHIP_SELECT</id>\n"; if( $proc % 2 == 0 ) # proc0 of DCM { print " <default>0x00</default><!-- CS0 -->\n"; } else # proc1 of DCM { print " <default>0xFF</default><!-- NONE -->\n"; } print " </attribute>\n"; print " <attribute>\n"; print " <id>PM_PBAX_NODEID</id>\n"; print " <default>0</default>\n"; print " </attribute>\n"; print " <attribute>\n"; print " <id>PM_PBAX_CHIPID</id>\n"; print " <default>$logid</default>\n"; print " </attribute>\n"; print " <attribute>\n"; print " <id>PM_PBAX_BRDCST_ID_VECTOR</id>\n"; print " <default>$lognode</default>\n"; print " </attribute>\n"; print " <attribute>\n"; print " <id>PM_SLEEP_ENTRY</id>\n"; print " <default>0x0</default>\n"; print " </attribute>\n"; print " <attribute>\n"; print " <id>PM_SLEEP_EXIT</id>\n"; print " <default>0x0</default>\n"; print " </attribute>\n"; print " <attribute>\n"; print " <id>PM_SLEEP_TYPE</id>\n"; print " <default>0x0</default>\n"; print " </attribute>\n"; print " <attribute>\n"; print " <id>PM_WINKLE_ENTRY</id>\n"; print " <default>0x0</default>\n"; print " </attribute>\n"; print " <attribute>\n"; print " <id>PM_WINKLE_EXIT</id>\n"; print " <default>0x0</default>\n"; print " </attribute>\n"; print " <attribute>\n"; print " <id>PM_WINKLE_TYPE</id>\n"; print " <default>0x0</default>\n"; print " </attribute>\n"; print " <!-- End PM_ attributes (default values) -->\n"; } else { print " <!-- PM_ attributes -->\n"; addProcPmAttrs( $proc, $node ); print " <!-- End PM_ attributes -->\n"; } print " </targetInstance>\n"; } sub generate_ex { my ($proc, $ex, $ordinalId, $ipath) = @_; my $uidstr = sprintf("0x%02X06%04X",${node},$proc*MAX_EX_PER_PROC + $ex); my $mruData = get_mruid($ipath); print " <targetInstance> <id>sys${sys}node${node}proc${proc}ex$ex</id> <type>unit-ex-$CHIPNAME</type> <attribute><id>HUID</id><default>${uidstr}</default></attribute> <attribute> <id>PHYS_PATH</id> <default>physical:sys-$sys/node-$node/proc-$proc/ex-$ex</default> </attribute> <attribute> <id>MRU_ID</id> <default>$mruData</default> </attribute> <attribute> <id>AFFINITY_PATH</id> <default>affinity:sys-$sys/node-$node/proc-$proc/ex-$ex</default> </attribute> <compileAttribute> <id>INSTANCE_PATH</id> <default>instance:$ipath</default> </compileAttribute> <attribute> <id>CHIP_UNIT</id> <default>$ex</default> </attribute>"; # call to do any fsp per-ex attributes do_plugin('fsp_ex', $proc, $ex, $ordinalId ); print " </targetInstance> "; } sub generate_ex_core { my ($proc, $ex, $ordinalId, $ipath) = @_; my $uidstr = sprintf("0x%02X07%04X",${node},$proc*MAX_EX_PER_PROC + $ex); my $mruData = get_mruid($ipath); print " <targetInstance> <id>sys${sys}node${node}proc${proc}ex${ex}core0</id> <type>unit-core-$CHIPNAME</type> <attribute><id>HUID</id><default>${uidstr}</default></attribute> <attribute> <id>PHYS_PATH</id> <default>physical:sys-$sys/node-$node/proc-$proc/ex-$ex/core-0</default> </attribute> <attribute> <id>MRU_ID</id> <default>$mruData</default> </attribute> <attribute> <id>AFFINITY_PATH</id> <default>affinity:sys-$sys/node-$node/proc-$proc/ex-$ex/core-0</default> </attribute> <compileAttribute> <id>INSTANCE_PATH</id> <default>instance:$ipath</default> </compileAttribute> <attribute> <id>CHIP_UNIT</id> <default>$ex</default> </attribute>"; # call to do any fsp per-ex_core attributes do_plugin('fsp_ex_core', $proc, $ex, $ordinalId ); print " </targetInstance> "; } sub generate_mcs { my ($proc, $mcs, $ordinalId, $ipath) = @_; my $uidstr = sprintf("0x%02X0B%04X",${node},$proc*MAX_MCS_PER_PROC + $mcs); my $mruData = get_mruid($ipath); my $lognode; my $logid; for (my $j = 0; $j <= $#chipIDs; $j++) { if ($chipIDs[$j][CHIP_ID_NXPX] eq "n${node}:p${proc}") { $lognode = $chipIDs[$j][CHIP_ID_NODE]; $logid = $chipIDs[$j][CHIP_ID_POS]; last; } } #IBSCOM address range starts at 0x0003E00000000000 (992 TB) #128GB per MCS/Centaur #Addresses assigned by logical node, not physical node my $mscStr = sprintf("0x%016X", 0x0003E00000000000 + 0x40000000000*$lognode + 0x10000000000*$logid + 0x2000000000*$mcs); my $lane_swap = 0; my $msb_swap = 0; my $swizzle = 0; foreach my $dmi ( @dbus_mcs ) { if (($dmi->[DBUS_MCS_NODE_INDEX] eq ${node} ) && ( $dmi->[DBUS_MCS_PROC_INDEX] eq $proc ) && ($dmi->[DBUS_MCS_UNIT_INDEX] eq $mcs )) { $lane_swap = $dmi->[DBUS_MCS_DOWNSTREAM_INDEX]; $msb_swap = $dmi->[DBUS_MCS_TX_SWAP_INDEX]; $swizzle = $dmi->[DBUS_MCS_SWIZZLE_INDEX]; last; } } print " <targetInstance> <id>sys${sys}node${node}proc${proc}mcs$mcs</id> <type>unit-mcs-$CHIPNAME</type> <attribute><id>HUID</id><default>${uidstr}</default></attribute> <attribute> <id>PHYS_PATH</id> <default>physical:sys-$sys/node-$node/proc-$proc/mcs-$mcs</default> </attribute> <attribute> <id>MRU_ID</id> <default>$mruData</default> </attribute> <attribute> <id>AFFINITY_PATH</id> <default>affinity:sys-$sys/node-$node/proc-$proc/mcs-$mcs</default> </attribute> <compileAttribute> <id>INSTANCE_PATH</id> <default>instance:$ipath</default> </compileAttribute> <attribute> <id>CHIP_UNIT</id> <default>$mcs</default> </attribute> <attribute><id>IBSCOM_MCS_BASE_ADDR</id> <!-- baseAddr = 0x0003E00000000000, 128GB per MCS --> <default>$mscStr</default> </attribute> <attribute><id>DMI_REFCLOCK_SWIZZLE</id> <default>$swizzle</default> </attribute> <attribute> <id>EI_BUS_TX_MSBSWAP</id> <default>$msb_swap</default> </attribute> <attribute> <id>EI_BUS_TX_LANE_INVERT</id> <default>$lane_swap</default> </attribute>"; # call to do any fsp per-mcs attributes do_plugin('fsp_mcs', $proc, $mcs, $ordinalId ); print " </targetInstance> "; } sub generate_pcies { my ($proc,$ordinalId) = @_; my $proc_name = "n${node}:p${proc}"; print "\n<!-- $SYSNAME n${node}p${proc} PCI units -->\n"; my $max_index = 2; # TODO RTC: 94803 if ($CHIPNAME eq "venice") { $max_index = 3; } my $max_pcie = $max_index+1; for my $i ( 0 .. $max_index ) { generate_a_pcie( $proc, $i, $max_pcie, ($ordinalId*$max_pcie)+$i ); } } my $phbInit = 0; my %phbList = (); sub generate_phb { my $targets_file = open_mrw_file($::mrwdir, "${sysname}-targets.xml"); my $phbTargets = parse_xml_file($targets_file); #get the PHB details foreach my $Target (@{$phbTargets->{target}}) { if($Target->{'ecmd-common-name'} eq "phb") { my $node = $Target->{'node'}; my $proc = $Target->{'position'}; my $chipUnit = $Target->{'chip-unit'}; my $ipath = $Target->{'instance-path'}; $phbList{$node}{$proc}{$chipUnit} = { 'node' => $node, 'proc' => $proc, 'phbChipUnit' => $chipUnit, 'phbIpath' => $ipath, } } } } sub generate_a_pcie { my ($proc, $phb, $max_pcie, $ordinalId) = @_; my $uidstr = sprintf("0x%02X10%04X",${node},$proc*$max_pcie + $phb); # Get the PHB info if ($phbInit == 0) { generate_phb; $phbInit = 1; } print " <targetInstance> <id>sys${sys}node${node}proc${proc}pci${phb}</id> <type>unit-pci-$CHIPNAME</type> <attribute><id>HUID</id><default>${uidstr}</default></attribute> <attribute> <id>PHYS_PATH</id> <default>physical:sys-$sys/node-$node/proc-$proc/pci-$phb</default> </attribute> <attribute> <id>AFFINITY_PATH</id> <default>affinity:sys-$sys/node-$node/proc-$proc/pci-$phb</default> </attribute> <compileAttribute> <id>INSTANCE_PATH</id> <default>instance:$phbList{$node}{$proc}{$phb}->{'phbIpath'}</default> </compileAttribute> <attribute> <id>CHIP_UNIT</id> <default>$phb</default> </attribute>"; # call to do any fsp per-pcie attributes do_plugin('fsp_pcie', $proc, $phb, $ordinalId ); print " </targetInstance> "; } sub getBusInfo { my($type, $chipName) = @_; my $minbus = ($type eq "A") ? 0 : ($chipName eq "murano") ? 1 : 0; my $maxbus = ($type eq "A") ? 2 : ($chipName eq "murano") ? 1 : 3; my $numperchip = ($type eq "A") ? MAX_ABUS_PER_PROC : MAX_XBUS_PER_PROC; my $typenum = ($type eq "A") ? 0x0F : 0x0E; $type = lc( $type ); return ($minbus, $maxbus, $numperchip, $typenum, $type); } sub generate_ax_buses { my ($proc, $type, $ordinalId) = @_; my $proc_name = "n${node}p${proc}"; print "\n<!-- $SYSNAME $proc_name ${type}BUS units -->\n"; my ($minbus, $maxbus, $numperchip, $typenum, $type) = getBusInfo($type, $CHIPNAME); for my $i ( $minbus .. $maxbus ) { my $c_ordinalId = $i+($ordinalId*($numperchip)); my $peer = 0; my $p_node = 0; my $p_proc = 0; my $p_port = 0; my $lane_swap = 0; my $msb_swap = 0; my $ipath = "abus_or_xbus:TO_BE_ADDED"; my $node_config = "null"; foreach my $pbus ( @pbus ) { if ($pbus->[PBUS_FIRST_END_POINT_INDEX] eq "n${node}:p${proc}:${type}${i}" ) { $ipath = $pbus->[PBUS_ENDPOINT_INSTANCE_PATH]; if ($pbus->[PBUS_SECOND_END_POINT_INDEX] ne "invalid") { $peer = 1; $p_proc = $pbus->[PBUS_SECOND_END_POINT_INDEX]; $p_port = $p_proc; $p_node = $pbus->[PBUS_SECOND_END_POINT_INDEX]; $p_node =~ s/^n(.*):p.*:.*$/$1/; $p_proc =~ s/^.*:p(.*):.*$/$1/; $p_port =~ s/.*:p.*:.(.*)$/$1/; $node_config = $pbus->[PBUS_NODE_CONFIG_FLAG]; # Calculation from Pete Thomsen for 'master' chip if(((${node}*100) + $proc) < (($p_node*100) + $p_proc)) { # This chip is lower so it's master so it gets # the downstream data. $lane_swap = $pbus->[PBUS_DOWNSTREAM_INDEX]; $msb_swap = $pbus->[PBUS_TX_MSB_LSB_SWAP]; } else { # This chip is higher so it's the slave chip # and gets the upstream $lane_swap = $pbus->[PBUS_UPSTREAM_INDEX]; $msb_swap = $pbus->[PBUS_RX_MSB_LSB_SWAP]; } last; } } } my $mruData = get_mruid($ipath); my $phys_path = "physical:sys-${sys}/node-${node}/proc-${proc}/${type}bus-${i}"; print " <targetInstance> <id>sys${sys}node${node}proc${proc}${type}bus$i</id> <type>unit-${type}bus-$CHIPNAME</type> <attribute> <id>HUID</id> <default>$hash_ax_buses->{$phys_path}</default> </attribute> <attribute> <id>PHYS_PATH</id> <default>$phys_path</default> </attribute> <attribute> <id>MRU_ID</id> <default>$mruData</default> </attribute> <attribute> <id>AFFINITY_PATH</id> <default>affinity:sys-$sys/node-$node/proc-$proc/${type}bus-$i</default> </attribute> <compileAttribute> <id>INSTANCE_PATH</id> <default>instance:$ipath</default> </compileAttribute> <attribute> <id>CHIP_UNIT</id> <default>$i</default> </attribute>"; if ($peer) { my $peerPhysPath = "physical:sys-${sys}/node-${p_node}/" ."proc-${p_proc}/${type}bus-${p_port}"; if ( $type eq "a" ) { # Brazos : Generate ABUS peer info only for "2-node" and "all" # configuration. # All other targets(tuleta,alphine..etc) will have "all" # configuration. if( ($node_config eq "2-node") || ($node_config eq "all") ) { print " <attribute> <id>PEER_TARGET</id> <default>$peerPhysPath</default> </attribute> <compileAttribute> <id>PEER_HUID</id> <default>$hash_ax_buses->{$peerPhysPath}</default> </compileAttribute> <attribute> <id>PEER_PATH</id> <default>physical:sys-$sys/node-$p_node/proc-$p_proc/" . "${type}bus-$p_port</default> </attribute>"; } else { print " <attribute> <id>PEER_PATH</id> <default>physical:na</default> </attribute>"; } } else { print " <attribute> <id>PEER_TARGET</id> <default>$peerPhysPath</default> </attribute> <compileAttribute> <id>PEER_HUID</id> <default>$hash_ax_buses->{$peerPhysPath}</default> </compileAttribute>"; } if (($node != $p_node) && ($type eq "a")) { print " <attribute> <id>IS_INTER_ENCLOSURE_BUS</id> <default>1</default> </attribute>"; } } else { if ($type eq "a") { print " <attribute> <id>PEER_PATH</id> <default>physical:na</default> </attribute>"; } } # call to do any fsp per-axbus attributes do_plugin('fsp_axbus', $proc, $type, $i, $c_ordinalId ); if($type eq "a") { print " <attribute> <id>EI_BUS_TX_LANE_INVERT</id> <default>$lane_swap</default> </attribute> <attribute> <id>EI_BUS_TX_MSBSWAP</id> <default>$msb_swap</default> </attribute>"; } print "\n</targetInstance>\n"; } } my $poreNxInit = 0; my %poreList = (); my %nxList = (); sub generate_pore_nx_ipath { #get the PORE ipath detail using previously computed $eTargets foreach my $Target (@{$eTargets->{target}}) { if($Target->{'ecmd-common-name'} eq "pore") { my $ipath = $Target->{'instance-path'}; my $node = $Target->{node}; my $position = $Target->{position}; $poreList{$node}{$position} = { 'node' => $node, 'position' => $position, 'instancePath' => $ipath, } } #get the nx ipath detail if($Target->{'ecmd-common-name'} eq "nx") { my $ipath = $Target->{'instance-path'}; my $node = $Target->{node}; my $position = $Target->{position}; $nxList{$node}{$position} = { 'node' => $node, 'position' => $position, 'instancePath' => $ipath, } } } } sub generate_nx { my ($proc, $ordinalId, $node) = @_; my $uidstr = sprintf("0x%02X1E%04X",${node},$proc); # Get the nx and PORE info if ($poreNxInit == 0) { generate_pore_nx_ipath; $poreNxInit = 1; } my $ipath = $nxList{$node}{$proc}->{'instancePath'}; my $mruData = get_mruid($ipath); print "\n<!-- $SYSNAME n${node}p$proc NX units -->\n"; print " <targetInstance> <id>sys${sys}node${node}proc${proc}nx0</id> <type>unit-nx-$CHIPNAME</type> <attribute><id>HUID</id><default>${uidstr}</default></attribute> <attribute> <id>PHYS_PATH</id> <default>physical:sys-$sys/node-$node/proc-$proc/nx-0</default> </attribute> <attribute> <id>MRU_ID</id> <default>$mruData</default> </attribute> <attribute> <id>AFFINITY_PATH</id> <default>affinity:sys-$sys/node-$node/proc-$proc/nx-0</default> </attribute> <compileAttribute> <id>INSTANCE_PATH</id> <default>instance:$ipath</default> </compileAttribute> <attribute> <id>CHIP_UNIT</id> <default>0</default> </attribute>"; # call to do any fsp per-nx attributes do_plugin('fsp_nx', $proc, $ordinalId ); print " </targetInstance> "; } sub generate_pore { my ($proc, $ordinalId, $node) = @_; my $uidstr = sprintf("0x%02X1F%04X",${node},$proc); # Get the nx and PORE info if ($poreNxInit == 0) { generate_pore_nx_ipath; $poreNxInit = 1; } my $ipath = $poreList{$node}{$proc}->{'instancePath'}; my $mruData = get_mruid($ipath); print "\n<!-- $SYSNAME n${node}p$proc PORE units -->\n"; print " <targetInstance> <id>sys${sys}node${node}proc${proc}pore0</id> <type>unit-pore-$CHIPNAME</type> <attribute><id>HUID</id><default>${uidstr}</default></attribute> <attribute> <id>PHYS_PATH</id> <default>physical:sys-$sys/node-$node/proc-$proc/pore-0</default> </attribute> <attribute> <id>MRU_ID</id> <default>$mruData</default> </attribute> <attribute> <id>AFFINITY_PATH</id> <default>affinity:sys-$sys/node-$node/proc-$proc/pore-0</default> </attribute> <compileAttribute> <id>INSTANCE_PATH</id> <default>instance:$ipath</default> </compileAttribute> <attribute> <id>CHIP_UNIT</id> <default>0</default> </attribute>"; # call to do any fsp per-pore attributes do_plugin('fsp_pore', $proc, $ordinalId ); print " </targetInstance> "; } sub generate_capp { my ($proc, $ordinalId, $node) = @_; my $uidstr = sprintf("0x%02X21%04X",${node},$proc); # TODO RTC: 97477 my $ipath = ""; my $mruData = ""; print "\n<!-- $SYSNAME n${node}p$proc capp units -->\n"; print " <targetInstance> <id>sys${sys}node${node}proc${proc}capp0</id> <type>unit-capp-$CHIPNAME</type> <attribute><id>HUID</id><default>${uidstr}</default></attribute> <attribute> <id>PHYS_PATH</id> <default>physical:sys-$sys/node-$node/proc-$proc/capp-0</default> </attribute> <attribute> <id>MRU_ID</id>"; # TODO RTC: 97477 print " <default>0</default> </attribute> <attribute> <id>AFFINITY_PATH</id> <default>affinity:sys-$sys/node-$node/proc-$proc/capp-0</default> </attribute> <compileAttribute> <id>INSTANCE_PATH</id>"; # TODO RTC: 97477 print " <default>instance:TO_BE_ADDED</default> </compileAttribute> <attribute> <id>CHIP_UNIT</id> <default>0</default> </attribute>"; # call to do any fsp per-capp attributes do_plugin('fsp_capp', $proc, $ordinalId ); print " </targetInstance> "; } my $logicalDimmInit = 0; my %logicalDimmList = (); sub generate_logicalDimms { my $memory_busses_file = open_mrw_file($::mrwdir, "${sysname}-memory-busses.xml"); my $dramTargets = parse_xml_file($memory_busses_file); #get the DRAM details foreach my $Target (@{$dramTargets->{drams}->{dram}}) { my $node = $Target->{'assembly-position'}; my $ipath = $Target->{'dram-instance-path'}; my $dimmIpath = $Target->{'dimm-instance-path'}; my $mbaIpath = $Target->{'mba-instance-path'}; my $mbaPort = $Target->{'mba-port'}; my $mbaSlot = $Target->{'mba-slot'}; my $dimm = substr($dimmIpath, index($dimmIpath, 'dimm-')+5); my $mba = substr($mbaIpath, index($mbaIpath, 'mba')+3); $logicalDimmList{$node}{$dimm}{$mba}{$mbaPort}{$mbaSlot} = { 'node' => $node, 'dimmIpath' => $dimmIpath, 'mbaIpath' => $mbaIpath, 'dimm' => $dimm, 'mba' => $mba, 'mbaPort' => $mbaPort, 'mbaSlot' => $mbaSlot, 'logicalDimmIpath' => $ipath, } } } sub generate_centaur { my ($ctaur, $mcs, $fsiA, $altfsiA, $ipath, $ordinalId, $relativeCentaurRid, $ipath, $membufVrmUuidHash) = @_; my @fsi = @{$fsiA}; my @altfsi = @{$altfsiA}; my $scomFspApath = $devpath->{chip}->{$ipath}->{'scom-path-a'}; my $scanFspApath = $devpath->{chip}->{$ipath}->{'scan-path-a'}; my $scomFspAsize = length($scomFspApath) + 1; my $scanFspAsize = length($scanFspApath) + 1; my $scomFspBpath = ""; if (ref($devpath->{chip}->{$ipath}->{'scom-path-b'}) ne "HASH") { $scomFspBpath = $devpath->{chip}->{$ipath}->{'scom-path-b'}; } my $scanFspBpath = ""; if (ref($devpath->{chip}->{$ipath}->{'scan-path-b'}) ne "HASH") { $scanFspBpath = $devpath->{chip}->{$ipath}->{'scan-path-b'}; } my $scomFspBsize = length($scomFspBpath) + 1; my $scanFspBsize = length($scanFspBpath) + 1; my $proc = $mcs; $proc =~ s/.*:p(.*):.*/$1/g; $mcs =~ s/.*:.*:mcs(.*)/$1/g; my $mruData = get_mruid($ipath); my $uidstr = sprintf("0x%02X04%04X",${node},$proc*MAX_MCS_PER_PROC + $mcs); my $lane_swap = 0; my $msb_swap = 0; foreach my $dmi ( @dbus_centaur ) { if (($dmi->[DBUS_CENTAUR_NODE_INDEX] eq ${node} ) && ($dmi->[DBUS_CENTAUR_MEMBUF_INDEX] eq $ctaur) ) { $lane_swap = $dmi->[DBUS_CENTAUR_UPSTREAM_INDEX]; $msb_swap = $dmi->[DBUS_CENTAUR_RX_SWAP_INDEX]; last; } } # Get the logical DIMM info if ($logicalDimmInit == 0) { generate_logicalDimms; $logicalDimmInit = 1; } print " <!-- $SYSNAME Centaur n${node}p${ctaur} : start --> <targetInstance> <id>sys${sys}node${node}membuf${ctaur}</id> <type>chip-membuf-centaur</type> <attribute><id>HUID</id><default>${uidstr}</default></attribute> <attribute><id>POSITION</id><default>$ctaur</default></attribute> <attribute> <id>PHYS_PATH</id> <default>physical:sys-$sys/node-$node/membuf-$ctaur</default> </attribute> <attribute> <id>MRU_ID</id> <default>$mruData</default> </attribute> <attribute> <id>AFFINITY_PATH</id> <default>affinity:sys-$sys/node-$node/proc-$proc/mcs-$mcs/" . "membuf-$ctaur</default> </attribute> <compileAttribute> <id>INSTANCE_PATH</id> <default>instance:$ipath</default> </compileAttribute> <attribute> <id>EI_BUS_TX_MSBSWAP</id> <default>$msb_swap</default> </attribute>"; # FSI Connections # if( $#fsi <= 0 ) { die "\n*** No valid FSI link found for Centaur $ctaur ***\n"; } print "\n <!-- FSI connections --> <attribute> <id>FSI_MASTER_TYPE</id> <default>CMFSI</default> </attribute> <attribute> <id>FSI_SLAVE_CASCADE</id> <default>0</default> </attribute> <attribute> <id>FSI_OPTION_FLAGS</id> <default> <field><id>flipPort</id><value>0</value></field> <field><id>reserved</id><value>0</value></field> </default> </attribute>"; my $mNode = $fsi[FSI_MASTERNODE_FIELD]; my $mPos = $fsi[FSI_MASTERPOS_FIELD]; my $link = $fsi[FSI_LINK_FIELD]; print " <!-- FSI-A is connected via node$mNode:proc$mPos:CMFSI-$link --> <attribute> <id>FSI_MASTER_CHIP</id> <default>physical:sys-$sys/node-$mNode/proc-$mPos</default> </attribute> <attribute> <id>FSI_MASTER_PORT</id> <default>$link</default> </attribute>"; if( $#altfsi <= 0 ) { print " <!-- FSI-B is not connected --> <attribute> <id>ALTFSI_MASTER_CHIP</id> <default>physical:sys</default><!-- no B path --> </attribute> <attribute> <id>ALTFSI_MASTER_PORT</id> <default>0xFF</default><!-- no B path --> </attribute>\n"; } else { $mNode = $altfsi[FSI_MASTERNODE_FIELD]; $mPos = $altfsi[FSI_MASTERPOS_FIELD]; $link = $altfsi[FSI_LINK_FIELD]; print " <!-- FSI-B is connected via node$mNode:proc$mPos:CMFSI-$link --> <attribute> <id>ALTFSI_MASTER_CHIP</id> <default>physical:sys-$sys/node-$mNode/proc-$mPos</default> </attribute> <attribute> <id>ALTFSI_MASTER_PORT</id> <default>$link</default> </attribute>\n"; } print " <!-- End FSI connections -->\n"; # End FSI # print " <attribute><id>VPD_REC_NUM</id><default>$ctaur</default></attribute> <attribute> <id>EI_BUS_TX_LANE_INVERT</id> <default>$lane_swap</default> </attribute>"; foreach my $vrmType ( keys %$membufVrmUuidHash ) { my $key = $membufVrmUuidHash->{$vrmType}{VRM_UUID}; print "\n" . " <attribute>\n" . " <id>$vrmType" . "_ID</id>\n" . " <default>$vrmHash{$key}{VRM_DOMAIN_ID}</default>\n" . " </attribute>"; } # call to do any fsp per-centaur attributes do_plugin('fsp_centaur', $scomFspApath, $scomFspAsize, $scanFspApath, $scanFspAsize, $scomFspBpath, $scomFspBsize, $scanFspBpath, $scanFspBsize, $relativeCentaurRid, $ordinalId, $membufVrmUuidHash); print "\n</targetInstance>\n"; } sub generate_mba { my ($ctaur, $mcs, $mba, $ordinalId, $ipath) = @_; my $proc = $mcs; $proc =~ s/.*:p(.*):.*/$1/g; $mcs =~ s/.*:.*:mcs(.*)/$1/g; my $uidstr = sprintf("0x%02X0D%04X", ${node},($proc * MAX_MCS_PER_PROC + $mcs)* MAX_MBA_PER_MEMBUF + $mba); my $mruData = get_mruid($ipath); print " <targetInstance> <id>sys${sys}node${node}membuf${ctaur}mba$mba</id> <type>unit-mba-centaur</type> <attribute><id>HUID</id><default>${uidstr}</default></attribute> <attribute> <id>PHYS_PATH</id> <default>physical:sys-$sys/node-$node/membuf-$ctaur/" . "mba-$mba</default> </attribute> <attribute> <id>MRU_ID</id> <default>$mruData</default> </attribute> <attribute> <id>AFFINITY_PATH</id> <default>affinity:sys-$sys/node-$node/proc-$proc/mcs-$mcs/" . "membuf-$ctaur/mba-$mba</default> </attribute> <compileAttribute> <id>INSTANCE_PATH</id> <default>instance:$ipath</default> </compileAttribute> <attribute> <id>CHIP_UNIT</id> <default>$mba</default> </attribute>"; # call to do any fsp per-mba attributes do_plugin('fsp_mba', $ctaur, $mba, $ordinalId ); print " </targetInstance> "; } sub generate_l4 { my ($ctaur, $mcs, $l4, $ordinalId, $ipath) = @_; my $proc = $mcs; $proc =~ s/.*:p(.*):.*/$1/g; $mcs =~ s/.*:.*:mcs(.*)/$1/g; my $uidstr = sprintf("0x%02X0A%04X",${node},$proc*MAX_MCS_PER_PROC + $mcs); my $mruData = get_mruid($ipath); print " <targetInstance> <id>sys${sys}node${node}membuf${ctaur}l4${l4}</id> <type>unit-l4-centaur</type> <attribute><id>HUID</id><default>${uidstr}</default></attribute> <attribute> <id>PHYS_PATH</id> <default>physical:sys-$sys/node-$node/membuf-$ctaur/" . "l4-$l4</default> </attribute> <attribute> <id>AFFINITY_PATH</id> <default>affinity:sys-$sys/node-$node/proc-$proc/mcs-$mcs/" . "membuf-$ctaur/l4-$l4</default> </attribute> <attribute> <id>MRU_ID</id> <default>$mruData</default> </attribute> <compileAttribute> <id>INSTANCE_PATH</id> <default>instance:$ipath</default> </compileAttribute> <attribute> <id>CHIP_UNIT</id> <default>$l4</default> </attribute>"; # call to do any fsp per-centaur_l4 attributes do_plugin('fsp_centaur_l4', $ctaur, $ordinalId ); print "</targetInstance>"; } # Since each Centaur has only one dimm, it is assumed to be attached to port 0 # of the MBA0 chiplet. sub generate_dimm { my ($proc, $mcs, $ctaur, $pos, $dimm, $id, $ordinalId, $relativeDimmRid, $relativePos) = @_; my $x = $id; $x = int ($x / 4); my $y = $id; $y = int(($y - 4 * $x) / 2); my $z = $id; $z = $z % 2; my $zz = $id; $zz = $zz % 4; #$x = sprintf ("%d", $x); #$y = sprintf ("%d", $y); #$z = sprintf ("%d", $z); #$zz = sprintf ("%d", $zz); my $uidstr = sprintf("0x%02X03%04X",${node},$dimm); # Calculate the VPD Record number value my $vpdRec = 0; # Set offsets based on mba and dimm values if( 1 == $x ) { $vpdRec = $vpdRec + 4; } if( 1 == $y ) { $vpdRec = $vpdRec + 2; } if( 1 == $z ) { $vpdRec = $vpdRec + 1; } my $position = ($proc * 64) + 8 * $mcs + $vpdRec; # Adjust offset based on MCS value $vpdRec = ($mcs * 8) + $vpdRec; # Adjust offset basedon processor value $vpdRec = ($proc * 64) + $vpdRec; my $dimmHex = sprintf("0xD0%02X",$relativePos + (CDIMM_RID_NODE_MULTIPLIER * ${node})); #MBA numbers should be 01 and 23 my $mbanum=0; if (1 ==$x ) { $mbanum = '23'; } else { $mbanum = '01'; } my $logicalDimmInstancePath = "instance:" . $logicalDimmList{$node}{$relativePos}{$mbanum}{$y}{$z}->{'logicalDimmIpath'}; print " <targetInstance> <id>sys${sys}node${node}dimm$dimm</id> <type>lcard-dimm-cdimm</type> <attribute><id>HUID</id><default>${uidstr}</default></attribute> <attribute><id>POSITION</id><default>$position</default></attribute> <attribute> <id>PHYS_PATH</id> <default>physical:sys-$sys/node-$node/dimm-$dimm</default> </attribute> <attribute> <id>AFFINITY_PATH</id> <default>affinity:sys-$sys/node-$node/proc-$proc/mcs-$mcs/" . "membuf-$pos/mba-$x/dimm-$zz</default> </attribute> <compileAttribute> <id>INSTANCE_PATH</id> <default>$logicalDimmInstancePath</default> </compileAttribute> <attribute> <id>MBA_DIMM</id> <default>$z</default> </attribute> <attribute> <id>MBA_PORT</id> <default>$y</default> </attribute> <attribute><id>VPD_REC_NUM</id><default>$vpdRec</default></attribute>"; # call to do any fsp per-dimm attributes do_plugin('fsp_dimm', $proc, $ctaur, $dimm, $ordinalId, $dimmHex ); print "\n</targetInstance>\n"; } sub addSysAttrs { for my $i (0 .. $#systemAttr) { my $j =0; my $sysAttrArraySize=$#{$systemAttr[$i]}; while ($j<$sysAttrArraySize) { # systemAttr is an array of pairs # even index is the attribute id # odd index has its default value my $l_default = $systemAttr[$i][$j+1]; if (substr($l_default,0,2) eq "0b") #convert bin to hex { $l_default = sprintf('0x%X', oct($l_default)); } print " <attribute>\n"; print " <id>$systemAttr[$i][$j]</id>\n"; print " <default>$l_default</default>\n"; print " </attribute>\n"; $j+=2; # next attribute id and default pair } } } sub addProcPmAttrs { my ($position,$nodeId) = @_; for my $i (0 .. $#SortedPmChipAttr) { if (($SortedPmChipAttr[$i][CHIP_POS_INDEX] == $position) && ($SortedPmChipAttr[$i][CHIP_NODE_INDEX] == $node) ) { #found the corresponding proc and node my $j =0; my $arraySize=$#{$SortedPmChipAttr[$i]} - CHIP_ATTR_START_INDEX; while ($j<$arraySize) { print " <attribute>\n"; print " <id>$SortedPmChipAttr[$i][CHIP_ATTR_START_INDEX+$j]</id>\n"; $j++; print " <default>$SortedPmChipAttr[$i][CHIP_ATTR_START_INDEX+$j]</default>\n"; print " </attribute>\n"; $j++; } } } } sub addProcPcieAttrs { my ($position,$nodeId) = @_; for my $i (0 .. $#SortedPcie) { if (($SortedPcie[$i][CHIP_POS_INDEX] == $position) && ($SortedPcie[$i][CHIP_NODE_INDEX] == $node) ) { #found the corresponding proc and node my $j =0; my $arraySize=$#{$SortedPcie[$i]} - CHIP_ATTR_START_INDEX; while ($j<$arraySize) { print " <attribute>\n"; print " <id>$SortedPcie[$i][CHIP_ATTR_START_INDEX+$j]</id>\n"; $j++; print " <default>\n"; print " $SortedPcie[$i][CHIP_ATTR_START_INDEX+$j]"; print ","; $j++; print "$SortedPcie[$i][CHIP_ATTR_START_INDEX+$j]\n"; print " </default>\n"; print " </attribute>\n"; $j++; } } } } # RTC 80614 - these values will eventually be pulled from the MRW sub addEeproms { my ($sys, $node, $proc) = @_; my $id_name eq ""; my $port = 0; my $devAddr = 0x00; my $mur_num = $proc % 2; for my $i (0 .. 3) { # Loops on $i # %i = 0 -> EEPROM_VPD_PRIMARY_INFO # %i = 1 -> EEPROM_VPD_BACKUP_INFO # %i = 2 -> EEPROM_SBE_PRIMARY_INFO # %i = 3 -> EEPROM_SBE_BACKUP_INFO # no EEPROM_VPD_BACKUP on Murano if ( ($i eq 1) && ($CHIPNAME eq "murano")) { next; } if($CHIPNAME eq "murano") { if ($i eq 0 ) { $id_name = "EEPROM_VPD_PRIMARY_INFO"; $port = 1; if ($mur_num eq 0) { $devAddr = 0xA4; } else { $devAddr = 0xA6; } } # $i = 1: EEPROM_VPD_BACKUP_INFO skipped above elsif ($i eq 2 ) { $id_name = "EEPROM_SBE_PRIMARY_INFO"; $port = 0; $devAddr = 0xAC; } elsif ($i eq 3 ) { $id_name = "EEPROM_SBE_BACKUP_INFO"; $port = 0; $devAddr = 0xAE; } } elsif ($CHIPNAME eq "venice") { if ($i eq 0 ) { $id_name = "EEPROM_VPD_PRIMARY_INFO"; $port = 0; $devAddr = 0xA0; } elsif ($i eq 1 ) { $id_name = "EEPROM_VPD_BACKUP_INFO"; $port = 1; $devAddr = 0xA0; } elsif ($i eq 2 ) { $id_name = "EEPROM_SBE_PRIMARY_INFO"; $port = 0; $devAddr = 0xA2; } elsif ($i eq 3 ) { $id_name = "EEPROM_SBE_BACKUP_INFO"; $port = 1; $devAddr = 0xA2; } } # make devAddr show as a hex number my $devAddr_hex = sprintf("0x%02X", $devAddr); print " <attribute>\n"; print " <id>$id_name</id>\n"; print " <default>\n"; print " <field><id>i2cMasterPath</id><value>physical:sys-$sys/node-$node/proc-$proc</value></field>\n"; print " <field><id>port</id><value>$port</value></field>\n"; print " <field><id>devAddr</id><value>$devAddr_hex</value></field>\n"; print " <field><id>engine</id><value>0</value></field>\n"; print " <field><id>byteAddrOffset</id><value>0x02</value></field>\n"; print " <field><id>maxMemorySizeKB</id><value>0x40</value></field>\n"; print " <field><id>writePageSize</id><value>0x80</value></field>\n"; print " <field><id>writeCycleTime</id><value>0x05</value></field>\n"; print " </default>\n"; print " </attribute>\n"; } } sub get_mruid { my($ipath) = @_; my $mruData = 0; foreach my $i (@{$mruAttr->{'mru-id'}}) { if ($ipath eq $i->{'instance-path'}) { $mruData = $i->{'mrid-value'}; last; } } return $mruData; } sub open_mrw_file { my ($paths, $filename) = @_; #Need to get list of paths to search my @paths_to_search = split /:/, $paths; my $file_found = ""; #Check for file at each directory in list foreach my $path (@paths_to_search) { if ( open (FH, "<$path/$filename") ) { $file_found = "$path/$filename"; close(FH); last; #break out of loop } } if ($file_found eq "") { #If the file was not found, build up error message and exit my $err_msg = "Could not find $filename in following paths:\n"; foreach my $path (@paths_to_search) { $err_msg = $err_msg." $path\n"; } die $err_msg; } else { #Return the full path to the file found return $file_found; } } my %g_xml_cache = (); sub parse_xml_file { my $parms = Dumper(\@_); if (not defined $g_xml_cache{$parms}) { $g_xml_cache{$parms} = XMLin(@_); } return $g_xml_cache{$parms}; } sub display_help { use File::Basename; my $scriptname = basename($0); print STDERR " Usage: $scriptname --help $scriptname --system=sysname --mrwdir=pathname [--build=hb] [--outfile=XmlFilename] --system=systemname Specify which system MRW XML to be generated --mrwdir=pathname Specify the complete dir pathname of the MRW. Colon-delimited list accepted to specify multiple directories to search. --build=hb Specify HostBoot build (hb) --outfile=XmlFilename Specify the filename for the output XML. If omitted, the output is written to STDOUT which can be saved by redirection. \n"; }
shenki/hostboot
src/usr/targeting/common/genHwsvMrwXml.pl
Perl
apache-2.0
122,619
#!/usr/bin/perl -w use strict; # take a fasta piped to standard input # take the number of reads to put in each file # take an output directory # will create that directory then put the fasta file broken into peices # named a by integer for each file. if(scalar(@ARGV) != 2) { die " cat my.fasta | ./explode_fasta.pl 500 myoutdir/\n"; } my $num = shift @ARGV; my $outdir = shift @ARGV; if(-d $outdir) { die "error $outdir already exists.. won't overwrite.\n"; } `mkdir $outdir`; my $seq = ''; my $name = ''; my $printed = $num+1; # force starting a new file my $filenum = 0; while(my $line = <STDIN>) { chomp($line); if($line=~/^(>.+)/) { my $oldname = $name; $name = $1; if($seq ne '') { if($printed >= $num) { $filenum++; close OF; open(OF,">$outdir/$filenum.fa") or die; $printed = 0; } $printed++; print OF "$oldname\n".$seq."\n"; } $seq = ''; } else { $line=~s/\s//g; $seq .= $line; } } if($seq ne '') { if($printed > $num) { $filenum++; close OF; open(OF,"$outdir/$filenum.fa") or die; $printed = 0; } $printed++; print OF "$name\n".$seq."\n"; } close OF;
jason-weirather/Au-public
iron/utilities/explode_fasta.pl
Perl
apache-2.0
1,181
# 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::Enums::CalloutPlaceholderFieldEnum; use strict; use warnings; use Const::Exporter enums => [ UNSPECIFIED => "UNSPECIFIED", UNKNOWN => "UNKNOWN", CALLOUT_TEXT => "CALLOUT_TEXT" ]; 1;
googleads/google-ads-perl
lib/Google/Ads/GoogleAds/V8/Enums/CalloutPlaceholderFieldEnum.pm
Perl
apache-2.0
809
#!/usr/bin/perl use strict; use warnings; use lib "../lib"; use lib "lib"; use Net::Limesco; use Data::Dumper; my ($hostname, $port) = @ARGV; my $lim = Net::Limesco->new($hostname, $port, 1); print Dumper($lim->getIssuers());
mrngm/limesco-pm
bin/get_issuers.pl
Perl
apache-2.0
228
=head1 LICENSE Copyright [1999-2014] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =cut use strict; use warnings; use SeqStoreConverter::BasicConverter; package SeqStoreConverter::DrosophilaMelanogaster; use vars qw(@ISA); @ISA = qw(SeqStoreConverter::BasicConverter); sub create_coord_systems { my $self = shift; $self->debug("DrosophilaMelanogaster Specific: creating " . "chunk and chromosome coord systems"); my $target = $self->target(); my $dbh = $self->dbh(); my $ass_def = $self->get_default_assembly(); my @coords = (["chromosome" , $ass_def, "default_version", 1 ], ["chunk", undef , "default_version,sequence_level", 2]); my @assembly_mappings = ("chromosome:$ass_def|chunk"); $self->debug("Building coord_system table"); my $sth = $dbh->prepare("INSERT INTO $target.coord_system " . "(name, version, attrib, rank) VALUES (?,?,?,?)"); my %coord_system_ids; foreach my $cs (@coords) { $sth->execute(@$cs); $coord_system_ids{$cs->[0]} = $sth->{'mysql_insertid'}; } $sth->finish(); $self->debug("Adding assembly.mapping entries to meta table"); $sth = $dbh->prepare("INSERT INTO $target.meta(meta_key, meta_value) " . "VALUES ('assembly.mapping', ?)"); foreach my $mapping (@assembly_mappings) { $sth->execute($mapping); } $sth->finish(); return; } sub create_seq_regions { my $self = shift; $self->debug("DrosophilaMelanogaster Specific: creating chunk and " . "chromosome seq_regions"); $self->contig_to_seq_region('chunk'); $self->chromosome_to_seq_region(); } sub create_assembly { my $self = shift; $self->debug("DrosophilaMelanogaster Specific: loading assembly data"); $self->assembly_contig_chromosome(); } 1;
willmclaren/ensembl
misc-scripts/surgery/SeqStoreConverter/DrosophilaMelanogaster.pm
Perl
apache-2.0
2,390
# # 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 network::juniper::common::junos::mode::cpuforwarding; 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', }, "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) = @_; $self->{snmp} = $options{snmp}; my $oid_jnxJsSPUMonitoringSPUIndex = '.1.3.6.1.4.1.2636.3.39.1.12.1.1.1.3'; my $oid_jnxJsSPUMonitoringCPUUsage = '.1.3.6.1.4.1.2636.3.39.1.12.1.1.1.4'; my $result = $self->{snmp}->get_table(oid => $oid_jnxJsSPUMonitoringSPUIndex, nothing_quit => 1); $self->{snmp}->load(oids => [$oid_jnxJsSPUMonitoringCPUUsage], instances => [keys %$result], instance_regexp => '\.(\d+)$'); my $result2 = $self->{snmp}->get_leef(nothing_quit => 1); foreach my $oid (keys %$result) { $oid =~ /\.(\d+)$/; my $instance = $1; my $cpu_usage = $result2->{$oid_jnxJsSPUMonitoringCPUUsage . '.' . $instance}; my $exit_code = $self->{perfdata}->threshold_check(value => $cpu_usage, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{output}->output_add(severity => $exit_code, short_msg => sprintf("CPU '%d' average usage is: %s%%", $instance, $cpu_usage)); $self->{output}->perfdata_add(label => 'cpu_' . $instance, unit => '%', value => $cpu_usage, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), min => 0, max => 100); } $self->{output}->display(); $self->{output}->exit(); } 1; __END__ =head1 MODE Check CPU Usage of packet forwarding engine. =over 8 =item B<--warning> Threshold warning in percent. =item B<--critical> Threshold critical in percent. =back =cut
wilfriedcomte/centreon-plugins
network/juniper/common/junos/mode/cpuforwarding.pm
Perl
apache-2.0
3,955
#!/usr/bin/env perl =head1 LICENSE Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Copyright [2016-2020] 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 405ress 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 trim_peaks_to_seq_region_boundaries.pl =head1 SYNOPSIS =head1 DESCRIPTION perl scripts/sequencing/remove_intermediary_bam_files.pl \ --experiment GM19193_WCE_ChIP-Seq_control_TF_no1_ENCODE86 \ --registry /homes/mnuhn/work_dir_ersa/lib/ensembl-funcgen/registry.pm \ --species homo_sapiens experiments=`r2 -N mnuhn_testdb2_homo_sapiens_funcgen_91_38 -e "select name from experiment"` for experiment in $experiments do echo Processing $experiment perl scripts/sequencing/remove_intermediary_bam_files.pl \ --experiment $experiment \ --registry /homes/mnuhn/work_dir_ersa/lib/ensembl-funcgen/registry.pm \ --species homo_sapiens \ --data_root_dir /hps/nobackup/production/ensembl/mnuhn/chip_seq_analysis/dbfiles done perl scripts/sequencing/remove_intermediary_bam_files.pl \ --experiment IMR90_H3K27ac_ChIP-Seq_RoadmapEpigenomics85 \ --registry /homes/mnuhn/work_dir_ersa/lib/ensembl-funcgen/registry.pm \ --species homo_sapiens \ --data_root_dir /hps/nobackup/production/ensembl/mnuhn/chip_seq_analysis/dbfiles perl scripts/sequencing/remove_intermediary_bam_files.pl \ --registry /homes/mnuhn/work_dir_ersa/lib/ensembl-funcgen/registry.pm \ --species mus_musculus \ --data_root_dir /hps/nobackup/production/ensembl/mnuhn/chip_seq_analysis/dbfiles =cut use strict; use Data::Dumper; use Getopt::Long; use Bio::EnsEMBL::DBSQL::DBConnection; use Bio::EnsEMBL::DBSQL::DBAdaptor; use Bio::EnsEMBL::Utils::Logger; my $experiment_name; my $registry; my $species; my $data_root_dir; my %config_hash = ( 'experiment' => \$experiment_name, 'registry' => \$registry, 'species' => \$species, 'data_root_dir' => \$data_root_dir, ); my $result = GetOptions( \%config_hash, 'experiment=s', 'registry=s', 'species=s', 'data_root_dir=s', ); my $logger = Bio::EnsEMBL::Utils::Logger->new(); $logger->init_log; Bio::EnsEMBL::Registry->load_all($registry); my $experiment_adaptor = Bio::EnsEMBL::Registry->get_adaptor( $species, 'Funcgen', 'Experiment' ); my $alignment_adaptor = Bio::EnsEMBL::Registry->get_adaptor( $species, 'Funcgen', 'Alignment' ); my @experiment_list; if (defined $experiment_name) { my $experiment = $experiment_adaptor->fetch_by_name($experiment_name); push @experiment_list, $experiment; } else { @experiment_list = @{$experiment_adaptor->generic_fetch}; #die; } # print Dumper(map { $_->name } @experiment_list); # die; foreach my $experiment (@experiment_list) { remove_intermediary_bam_files_by_Experiment($experiment); } $logger->finish_log; sub remove_intermediary_bam_files_by_Experiment { my $experiment = shift; my $alignments_with_duplicates = $alignment_adaptor->fetch_all_with_duplicates_by_Experiment($experiment); $logger->info("Found " . scalar @$alignments_with_duplicates . " alignments with duplicates.\n"); ALIGNMENT: foreach my $alignment_with_duplicates (@$alignments_with_duplicates) { if (! $alignment_with_duplicates->has_bam_DataFile) { $logger->info($alignment_with_duplicates->name . " has no bam file.\n"); next ALIGNMENT; } my $bam_file = $alignment_with_duplicates->fetch_bam_DataFile; my $full_file_name = join '/', $data_root_dir, $bam_file->relative_ftp_site_path ; if (! -e $full_file_name) { $logger->error("Couldn't find alignment $full_file_name!\n"); $logger->finish_log; die; } $logger->info("Deleting $full_file_name\n"); unlink($full_file_name); $alignment_with_duplicates->_delete_bam_file_from_db; $bam_file->_delete_from_db; } }
Ensembl/ensembl-funcgen
scripts/sequencing/remove_intermediary_bam_files.pl
Perl
apache-2.0
4,569
package Paws::CodeBuild::BatchGetBuilds; use Moose; has Ids => (is => 'ro', isa => 'ArrayRef[Str|Undef]', traits => ['NameInRequest'], request_name => 'ids' , required => 1); use MooseX::ClassAttribute; class_has _api_call => (isa => 'Str', is => 'ro', default => 'BatchGetBuilds'); class_has _returns => (isa => 'Str', is => 'ro', default => 'Paws::CodeBuild::BatchGetBuildsOutput'); class_has _result_key => (isa => 'Str', is => 'ro'); 1; ### main pod documentation begin ### =head1 NAME Paws::CodeBuild::BatchGetBuilds - Arguments for method BatchGetBuilds on Paws::CodeBuild =head1 DESCRIPTION This class represents the parameters used for calling the method BatchGetBuilds on the AWS CodeBuild service. Use the attributes of this class as arguments to method BatchGetBuilds. You shouldn't make instances of this class. Each attribute should be used as a named argument in the call to BatchGetBuilds. As an example: $service_obj->BatchGetBuilds(Att1 => $value1, Att2 => $value2, ...); Values for attributes that are native types (Int, String, Float, etc) can passed as-is (scalar values). Values for complex Types (objects) can be passed as a HashRef. The keys and values of the hashref will be used to instance the underlying object. =head1 ATTRIBUTES =head2 B<REQUIRED> Ids => ArrayRef[Str|Undef] The IDs of the builds. =head1 SEE ALSO This class forms part of L<Paws>, documenting arguments for method BatchGetBuilds in L<Paws::CodeBuild> =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/CodeBuild/BatchGetBuilds.pm
Perl
apache-2.0
1,659
# # 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 cloud::azure::database::redis::mode::cachethroughput; use base qw(cloud::azure::custom::mode); use strict; use warnings; sub get_metrics_mapping { my ($self, %options) = @_; my $metrics_mapping = { 'cachewrite' => { 'output' => 'Cache Write Throughput', 'label' => 'cache-write-throughput', 'nlabel' => 'redis.cache.write.throughput.bytespersecond', 'unit' => 'B/s', 'min' => '0' }, 'cacheread' => { 'output' => 'Cache Read Throughput', 'label' => 'cache-read-throughput', 'nlabel' => 'redis.cache.read.throughput.bytespersecond', 'unit' => 'B/s', 'min' => '0' } }; return $metrics_mapping; } 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-metric:s' => { name => 'filter_metric' }, 'resource:s' => { name => 'resource' }, 'resource-group:s' => { name => 'resource_group' } }); return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); if (!defined($self->{option_results}->{resource}) || $self->{option_results}->{resource} eq '') { $self->{output}->add_option_msg(short_msg => 'Need to specify either --resource <name> with --resource-group option or --resource <id>.'); $self->{output}->option_exit(); } my $resource = $self->{option_results}->{resource}; my $resource_group = defined($self->{option_results}->{resource_group}) ? $self->{option_results}->{resource_group} : ''; if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.Cache\/Redis\/(.*)$/) { $resource_group = $1; $resource = $2; } $self->{az_resource} = $resource; $self->{az_resource_group} = $resource_group; $self->{az_resource_type} = 'Redis'; $self->{az_resource_namespace} = 'Microsoft.Cache'; $self->{az_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900; $self->{az_interval} = defined($self->{option_results}->{interval}) ? $self->{option_results}->{interval} : 'PT5M'; $self->{az_aggregations} = ['Maximum']; if (defined($self->{option_results}->{aggregation})) { $self->{az_aggregations} = []; foreach my $stat (@{$self->{option_results}->{aggregation}}) { if ($stat ne '') { push @{$self->{az_aggregations}}, ucfirst(lc($stat)); } } } foreach my $metric (keys %{$self->{metrics_mapping}}) { next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne '' && $metric !~ /$self->{option_results}->{filter_metric}/); push @{$self->{az_metrics}}, $metric; } } 1; __END__ =head1 MODE Check Azure Redis cache throughput statistics. Example: Using resource name : perl centreon_plugins.pl --plugin=cloud::azure::database::redis::plugin --mode=cache-throughput --custommode=api --resource=<redis_id> --resource-group=<resourcegroup_id> --aggregation='maximum' --warning-cache-read-throughput='800000' --critical-cache-read-throughput='900000' Using resource id : perl centreon_plugins.pl --plugin=cloud::azure::database::redis::plugin --mode=cache-throughput --custommode=api --resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.Cache/Redis/<redis_id>' --aggregation='maximum' --warning-cache-read-throughput='800000' --critical-cache-read-throughput='900000' Default aggregation: 'maximum' / 'minimum', 'total' and 'average' are valid. =over 8 =item B<--resource> Set resource name or id (Required). =item B<--resource-group> Set resource group (Required if resource's name is used). =item B<--warning-*> Warning threshold where '*' can be: 'cache-read-throughput', 'cache-write-throughput'. =item B<--critical-*> Critical threshold where '*' can be: 'cache-read-throughput', 'cache-write-throughput'. =back =cut
Tpo76/centreon-plugins
cloud/azure/database/redis/mode/cachethroughput.pm
Perl
apache-2.0
4,986
# please insert nothing before this line: -*- mode: cperl; cperl-indent-level: 4; cperl-continued-statement-offset: 4; indent-tabs-mode: nil -*- package TestAPI::uri; use strict; use warnings FATAL => 'all'; use Apache::Test; use Apache::TestUtil; use Apache::TestRequest; use APR::Pool (); use APR::URI (); use Apache2::URI (); use Apache2::RequestRec (); use Apache2::RequestUtil (); use Apache2::Const -compile => 'OK'; my $location = '/' . Apache::TestRequest::module2path(__PACKAGE__); sub handler { my $r = shift; plan $r, tests => 24; $r->args('query'); # basic { my $uri = $r->parsed_uri; ok $uri->isa('APR::URI'); ok t_cmp($uri->path, qr/^$location/, "path"); my $up = $uri->unparse; ok t_cmp($up, qr/^$location/, "unparse"); } # construct_server { my $server = $r->construct_server; ok t_cmp(join(':', $r->get_server_name, $r->get_server_port), $server, "construct_server/get_server_name/get_server_port"); } { my $hostname = "example.com"; my $server = $r->construct_server($hostname); ok t_cmp(join(':', $hostname, $r->get_server_port), $server, "construct_server($hostname)"); } { my $hostname = "example.com"; my $port = "9097"; my $server = $r->construct_server($hostname, $port); ok t_cmp(join(':', $hostname, $port), $server, "construct_server($hostname, $port)"); } { my $hostname = "example.com"; my $port = "9097"; my $server = $r->construct_server($hostname, $port, $r->pool->new); ok t_cmp(join(':', $hostname, $port), $server, "construct_server($hostname, $port, new_pool)"); } # construct_url { # if no args are passed then only $r->uri will be included (no # query and no fragment fields) my $curl = $r->construct_url; t_debug("construct_url: $curl"); t_debug("r->uri: " . $r->uri); my $parsed = APR::URI->parse($r->pool, $curl); ok $parsed->isa('APR::URI'); my $up = $parsed->unparse; ok t_cmp($up, qr/$location/, "unparse"); my $path = '/foo/bar'; $parsed->path($path); ok t_cmp($parsed->path, $path, "parsed path"); } { # this time include args in the constructed url my $fragment = "fragment"; $r->parsed_uri->fragment($fragment); my $curl = $r->construct_url(sprintf "%s?%s", $r->uri, $r->args); t_debug("construct_url: $curl"); t_debug("r->uri: ", $r->uri); my $parsed = APR::URI->parse($r->pool, $curl); my $up = $parsed->unparse; ok t_cmp($up, qr/$location/, 'construct_url($uri)'); ok t_cmp($parsed->query, $r->args, "args vs query"); } { # this time include args and a pool object my $curl = $r->construct_url(sprintf "%s?%s", $r->uri, $r->args, $r->pool->new); t_debug("construct_url: $curl"); t_debug("r->uri: ", $r->uri); my $up = APR::URI->parse($r->pool, $curl)->unparse; ok t_cmp($up, qr/$location/, 'construct_url($uri, $pool)'); } # segfault test { # test the segfault in apr < 0.9.2 (fixed on mod_perl side) # passing only the /path my $parsed = APR::URI->parse($r->pool, $r->uri); # set hostname, but not the scheme $parsed->hostname($r->get_server_name); $parsed->port($r->get_server_port); #$parsed->scheme('http'); my $expected = $r->construct_url; my $received = $parsed->unparse; t_debug("the real received is: $received"); # apr < 0.9.2-dev + fix in mpxs_apr_uri_unparse will return # '://localhost.localdomain:8529/TestAPI::uri' # apr >= 0.9.2 with internal fix will return # '//localhost.localdomain:8529/TestAPI::uri' # so in order to test pre-0.9.2 and post-0.9.2-dev we massage it $expected =~ s|^http:||; $received =~ s|^:||; ok t_cmp($received, $expected, "the bogus url is expected when 'hostname' is set " . "but not 'scheme'"); } # parse_uri { my $path = "/foo/bar"; my $query = "query"; my $fragment = "fragment"; my $newr = Apache2::RequestRec->new($r->connection, $r->pool); my $url_string = "$path?$query#$fragment"; # new request $newr->parse_uri($url_string); $newr->path_info('/bar'); ok t_cmp($newr->uri, $path, "uri"); ok t_cmp($newr->args, $query, "args"); ok t_cmp($newr->path_info, '/bar', "path_info"); my $puri = $newr->parsed_uri; ok t_cmp($puri->path, $path, "path"); ok t_cmp($puri->query, $query, "query"); ok t_cmp($puri->fragment, $fragment, "fragment"); #rpath ok t_cmp($puri->rpath, '/foo', "rpath"); my $port = 6767; $puri->port($port); $puri->scheme('ftp'); $puri->hostname('perl.apache.org'); ok t_cmp($puri->port, $port, "port"); ok t_cmp($puri->unparse, "ftp://perl.apache.org:$port$path?$query#$fragment", "unparse"); } # unescape_url { my @c = qw(one two three); my $url_string = join '%20', @c; Apache2::URI::unescape_url($url_string); ok $url_string eq "@c"; } Apache2::Const::OK; } 1;
dreamhost/dpkg-ndn-perl-mod-perl
t/response/TestAPI/uri.pm
Perl
apache-2.0
5,645
package Google::Ads::AdWords::v201402::AdGroupChangeData; use strict; use warnings; __PACKAGE__->_set_element_form_qualified(1); sub get_xmlns { 'https://adwords.google.com/api/adwords/ch/v201402' }; our $XML_ATTRIBUTE_CLASS; undef $XML_ATTRIBUTE_CLASS; sub __get_attr_class { return $XML_ATTRIBUTE_CLASS; } use Class::Std::Fast::Storable constructor => 'none'; use base qw(Google::Ads::SOAP::Typelib::ComplexType); { # BLOCK to scope variables my %adGroupId_of :ATTR(:get<adGroupId>); my %adGroupChangeStatus_of :ATTR(:get<adGroupChangeStatus>); my %changedAds_of :ATTR(:get<changedAds>); my %changedCriteria_of :ATTR(:get<changedCriteria>); my %deletedCriteria_of :ATTR(:get<deletedCriteria>); my %changedFeeds_of :ATTR(:get<changedFeeds>); my %deletedFeeds_of :ATTR(:get<deletedFeeds>); my %changedAdGroupBidModifierCriteria_of :ATTR(:get<changedAdGroupBidModifierCriteria>); my %deletedAdGroupBidModifierCriteria_of :ATTR(:get<deletedAdGroupBidModifierCriteria>); __PACKAGE__->_factory( [ qw( adGroupId adGroupChangeStatus changedAds changedCriteria deletedCriteria changedFeeds deletedFeeds changedAdGroupBidModifierCriteria deletedAdGroupBidModifierCriteria ) ], { 'adGroupId' => \%adGroupId_of, 'adGroupChangeStatus' => \%adGroupChangeStatus_of, 'changedAds' => \%changedAds_of, 'changedCriteria' => \%changedCriteria_of, 'deletedCriteria' => \%deletedCriteria_of, 'changedFeeds' => \%changedFeeds_of, 'deletedFeeds' => \%deletedFeeds_of, 'changedAdGroupBidModifierCriteria' => \%changedAdGroupBidModifierCriteria_of, 'deletedAdGroupBidModifierCriteria' => \%deletedAdGroupBidModifierCriteria_of, }, { 'adGroupId' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'adGroupChangeStatus' => 'Google::Ads::AdWords::v201402::ChangeStatus', 'changedAds' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'changedCriteria' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'deletedCriteria' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'changedFeeds' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'deletedFeeds' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'changedAdGroupBidModifierCriteria' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'deletedAdGroupBidModifierCriteria' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', }, { 'adGroupId' => 'adGroupId', 'adGroupChangeStatus' => 'adGroupChangeStatus', 'changedAds' => 'changedAds', 'changedCriteria' => 'changedCriteria', 'deletedCriteria' => 'deletedCriteria', 'changedFeeds' => 'changedFeeds', 'deletedFeeds' => 'deletedFeeds', 'changedAdGroupBidModifierCriteria' => 'changedAdGroupBidModifierCriteria', 'deletedAdGroupBidModifierCriteria' => 'deletedAdGroupBidModifierCriteria', } ); } # end BLOCK 1; =pod =head1 NAME Google::Ads::AdWords::v201402::AdGroupChangeData =head1 DESCRIPTION Perl data type class for the XML Schema defined complexType AdGroupChangeData from the namespace https://adwords.google.com/api/adwords/ch/v201402. Holds information about a changed adgroup =head2 PROPERTIES The following properties may be accessed using get_PROPERTY / set_PROPERTY methods: =over =item * adGroupId =item * adGroupChangeStatus =item * changedAds =item * changedCriteria =item * deletedCriteria =item * changedFeeds =item * deletedFeeds =item * changedAdGroupBidModifierCriteria =item * deletedAdGroupBidModifierCriteria =back =head1 METHODS =head2 new Constructor. The following data structure may be passed to new(): =head1 AUTHOR Generated by SOAP::WSDL =cut
gitpan/GOOGLE-ADWORDS-PERL-CLIENT
lib/Google/Ads/AdWords/v201402/AdGroupChangeData.pm
Perl
apache-2.0
3,798
#!/usr/bin/perl -w use strict; ##### pacbio_raw_to_subreads.pl ######## # Convert a .bas.h5 or .bax.h5 file into a fasta and fastq # Input: <input file name>, <output file name base> # Output: <output file name base>.fasta and <output file name base>.fastq # Modifies: Temporary files in /tmp/, STDIO, File IO and anything smrtanalysis is doing # Probably can only be called on the cluster since the VMs invoked by smrtanalysis won't be able to launch on the headnodes if(scalar(@ARGV) != 2) { die; } my $infile = shift @ARGV; my $basefile = shift @ARGV; my $username = $ENV{LOGNAME} || $ENV{USER} || getpwuid($<); #unless(-d "/tmp/$username") { # `mkdir /tmp/$username`; #} my $rand = int(rand()*100000000); my $path = "/localscratch/Users/$username/t".$rand; unless(-d "$path") { `mkdir $path`; } unless(-d "$path/mytemp") { `mkdir $path/mytemp`; } my $txml = $path."/input.xml"; print "$txml\n"; open(OF,">$txml") or die; print OF '<?xml version="1.0"?> <pacbioAnalysisInputs> <dataReferences> <url ref="run:0000000-0000"><location>'.$infile.'</location></url> </dataReferences> </pacbioAnalysisInputs>' . "\n"; close OF; my $tsettings = $path."/settings.xml"; print "$tsettings\n"; open(OF,">$tsettings") or die; print OF '<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <smrtpipeSettings> <protocol version="2.3.0" id="RS_Subreads.1" editable="false"> <application>Data Prep</application> <param name="name" label="Protocol Name"> <value>RS_Subreads</value> <input type="text"/> <rule required="true" message="Protocol name is required"/> </param> <param name="description"> <value>Filter subreads based on read length and quality, optionally splitting by barcode. Output FASTA and bas.h5 file of subreads.</value> <textarea></textarea> </param> <param name="version" hidden="true"> <value>1</value> <input type="text"/> <rule type="digits" required="true" min="1.0"/> </param> <param name="state"> <value>active</value> <input value="active" type="radio"/> <input value="inactive" type="radio"/> </param> <param name="control" hidden="true"> <value></value> </param> <param name="fetch" hidden="true"> <value>common/protocols/preprocessing/Fetch.1.xml</value> </param> <param name="filtering"> <value>common/protocols/filtering/SFilter.1.xml</value> <select multiple="true"> <import extension="xml" contentType="text/directory">common/protocols/filtering</import> </select> </param> <param name="barcode" editableInJob="true"> <value>common/protocols/barcode/NoBarcode.1.xml</value> <select multiple="false"> <import extension="xml" contentType="text/directory">common/protocols/barcode</import> </select> </param> </protocol> <moduleStage name="fetch" editable="true"> <module label="Fetch v1" id="P_Fetch" editableInJob="true"> <description>Sets up inputs</description> </module> </moduleStage> <moduleStage name="filtering" editable="true"> <module label="SFilter v1" id="P_Filter" editableInJob="true"> <description>This module filters reads based on a minimum subread length, polymerase read quality and polymerase read length.</description> <param name="minSubReadLength" label="Minimum Subread Length"> <value>50</value> <title>Subreads shorter than this value (in base pairs) are filtered out and excluded from analysis.</title> <input type="text" size="3"/> <rule type="number" min="0.0" message="Value must be a positive integer"/> </param> <param name="readScore" label="Minimum Polymerase Read Quality"> <value>75</value> <title>Polymerase reads with lower quality than this value are filtered out and excluded from analysis.</title> <input type="text"/> <rule type="number" min="0.0" message="Value must be between 0 and 100" max="100.0"/> </param> <param name="minLength" label="Minimum Polymerase Read Length"> <value>50</value> <title>Polymerase reads shorter than this value (in base pairs) are filtered out and excluded from analysis.</title> <input type="text" size="3"/> <rule type="number" min="0.0" message="Value must be a positive integer"/> </param> </module> <module label="SFilter Reports v1" id="P_FilterReports" editableInJob="false"/> </moduleStage> <moduleStage name="barcode" editable="true"/> <fileName>RS_Subreads.1.xml</fileName> </smrtpipeSettings>' . "\n"; close OF; my $cmd1 = "smrtpipe.py -D TMP=$path/mytemp -D SHARED_DIR=$path/mytemp --output=$path --params=$tsettings xml:$txml"; print "$cmd1\n"; open(INF,"$cmd1 |") or die; while(my $line = <INF>) { chomp($line); print "$line\n"; } close INF; `cp $path/data/filtered_subreads.fasta $basefile.fasta`; `cp $path/data/filtered_subreads.fastq $basefile.fastq`; `rm -r $path`; print "finished everything.. deleting folder $path and exiting.\n";
jason-weirather/Au-public
iron/utilities/pacbio_raw_to_subreads.pl
Perl
apache-2.0
5,435
use strict; package main; require("lib_inputCheck.pl"); # Set UserIndex $userIndex = setUserIndex(); # init message variables $sessionObj->param("userMessage", ""); $sessionObj->param("userMessage2", ""); my $errorMessage = ""; # Login is admin if ($sessionObj->param("role") eq "admin") { $adminName = $sessionObj->param("selectedAdmin"); my $templateName = trim($request->param('templateName')); securityCheckTemplateName($adminName, $templateName); $editName = trim($request->param('editName')); $editDescription = trim($request->param('editDescription')); $errorMessage = checkEditTemplateName($adminName, $templateName, $editName); if (length($errorMessage) != 0) { $sessionObj->param("userMessage2", $errorMessage); $queryString = "templateName=" . URLEncode($templateName) . "&editName=" . URLEncode($editName) . "&editDescription=" . URLEncode($editDescription) . "&editFlag=" . URLEncode($templateName); } else { updateTemplate($adminName, $templateName, $editName, $editDescription); $queryString = "templateName=" . URLEncode($editName); } } else { # Login is user die('ERROR: invalid value for $sessionObj->param("role")') } ################################################### SUBROUTINES #UPDATE TEMPLATE sub updateTemplate { my ($adminName, $templateName, $newTemplateName, $description) = @_; my $notificationTemplate = lock_retrieve("$perfhome/var/db/users/$adminName/alertTemplates/$templateName.ser") or die("Could not lock_retrieve from $perfhome/var/db/users/$adminName/alertTemplates/$templateName.ser\n"); $notificationTemplate->setName($newTemplateName); $notificationTemplate->setDescription($description); # Serialize new file $notificationTemplate->lock_store("$perfhome/var/db/users/$adminName/alertTemplates/$newTemplateName.ser") or die "ERROR: Can't store $perfhome/var/db/users/$adminName/alertTemplates/$newTemplateName.ser\n"; if ( $templateName ne $newTemplateName) { # delete old file name unlink "$perfhome/var/db/users/$adminName/alertTemplates/$templateName.ser" or die ("ERROR: Couldn't remove file $perfhome/var/db/users/$adminName/alertTemplates/$templateName.ser!\n"); } } 1;
ktenzer/perfstat
ui/appConfigs/alertTemplates/list/act_edit.pl
Perl
apache-2.0
2,187
# 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::V10::Services::CampaignCriterionService::CampaignCriterionOperation; use strict; use warnings; use base qw(Google::Ads::GoogleAds::BaseEntity); use Google::Ads::GoogleAds::Utils::GoogleAdsHelper; sub new { my ($class, $args) = @_; my $self = { create => $args->{create}, remove => $args->{remove}, update => $args->{update}, updateMask => $args->{updateMask}}; # Delete the unassigned fields in this object for a more concise JSON payload remove_unassigned_fields($self, $args); bless $self, $class; return $self; } 1;
googleads/google-ads-perl
lib/Google/Ads/GoogleAds/V10/Services/CampaignCriterionService/CampaignCriterionOperation.pm
Perl
apache-2.0
1,173
test4([a,b,a|A]) :- trans_conj__3(a,A), trace__5(agent(v2),prefix(b,stop),A). test4__1([a,b,a|A]) :- trans_conj__3(a,A), trace__5(agent(v2),prefix(b,stop),A). trans_conj__3(b,[]). trans_conj__3(a,[b,A|B]) :- trans_conj__3(A,B). trace__5(A,B,[]) :- stop__6(A,B). trace__5(A,B,[C|D]) :- trans_conj__7(A,B,C,D). stop__6(A,B) :- stop__9(A,B). stop__6(A,B). trans_conj__7(A,B,C,D) :- trans__8(A,C,E), trace__5(E,B,D). trans_conj__7(A,prefix(b,stop),b,B) :- trace__5(A,stop,B). trans__8(prefix(A,B),A,B). trans__8(interleave(A,B),C,interleave(D,B)) :- trans__8(A,C,D). trans__8(interleave(A,B),C,interleave(A,D)) :- trans__8(B,C,D). trans__8(agent(v2),a,interleave(agent(v2),prefix(b,stop))). stop__9(A,B) :- stop__10(A). stop__9(A,stop). stop__10(stop). stop__10(interleave(A,B)) :- stop__10(A). stop__10(interleave(A,B)) :- stop__10(B).
leuschel/ecce
ecce_examples/rultest.test4.pl
Perl
apache-2.0
912
#--------------------------------------------------- # libirc: an insanely flexible perl IRC library. | # Copyright (c) 2012-13, Mitchell Cooper | #--------------------------------------------------- package Evented::IRC::Pool; use warnings; use strict; use utf8; use 5.010; use Scalar::Util 'weaken'; # create a new pool. sub new { my ($class, %opts) = @_; my $pool = bless \%opts, $class; weaken($pool->{irc}); return $pool; } sub irc { shift->{irc} } ######################## ### MANAGING SERVERS ### ######################## # get server by ID or name. sub get_server { my ($pool, $id_or_name) = @_; return unless defined $id_or_name; return $pool->{servers}{$id_or_name} if defined $pool->{servers}{$id_or_name}; return defined $pool->{snames}{lc $id_or_name} ? $pool->{servers}{ $pool->{snames}{lc $id_or_name} } : undef; } # add a server to the pool. sub add_server { my ($pool, $server) = @_; return $server if exists $server->{id} && $pool->{servers}{$server}; # use the next available ID. my $id = $server->{id} = $pool->_next_server_id; # weakly reference to the server. # this will be strengthened when the server is retained. $pool->{servers}{$id} = $server; $pool->{ref_count}{$id} = 0; weaken($pool->{servers}{$id}); # reference to the pool. $server->{pool} = $pool; # store the server name. $pool->{snames}{ lc $server->{name} } = $id; # make the IRC object a listener. $server->add_listener($pool->irc, 'server'); return $server; } # remove a server from the pool. sub remove_server { my ($pool, $server) = @_; return unless $pool->{servers}{$server}; delete $pool->{snames}{ lc $server->{name} }; delete $pool->{servers}{$server}; return 1; } # change a server's name. sub set_server_name { my ($pool, $server, $old_name, $name) = @_; delete $pool->{snames}{lc $old_name}; $pool->{snames}{lc $name} = $server; } # fetch next available server ID. sub _next_server_id { my $pool = shift; $pool->{_sid} ||= 0; return $pool->irc->id.$pool->{_sid}++.q(s); } ######################### ### MANAGING CHANNELS ### ######################### # fetch a channel from its ID or name. sub get_channel { my ($pool, $name) = @_; return $pool->{channels}{$name} || $pool->{channels}{ $pool->irc->id.lc($name) } } # add channel to the pool. sub add_channel { my ($pool, $channel) = @_; return $channel if exists $channel->{id} && $pool->{channels}{$channel}; my $id = $channel->{id} = $pool->irc->id.lc($channel->{name}); # weakly reference to the channel. # this will be strengthened when the channel is retained. $pool->{channels}{$id} = $channel; weaken($pool->{channels}{$id}); # reference to the pool. $channel->{pool} = $pool; # make the IRC object a listener. $channel->add_listener($pool->irc, 'channel'); return $channel; } # remove a channel from the pool. sub remove_channel { my ($pool, $channel) = @_; delete $pool->{channels}{$channel}; } ###################### ### MANAGING USERS ### ###################### # if the passed value starts with a number, it is assumed to be # a user ID, and the method will return a user with that ID. # if it does not start with a number, it is assumed to be the # user's nickname, and a user with that nickname will be returned. sub get_user { my ($pool, $id_or_nick) = @_; return unless defined $id_or_nick; return $pool->{users}{$id_or_nick} if defined $pool->{users}{$id_or_nick}; return defined $pool->{nicks}{lc $id_or_nick} ? $pool->{users}{ $pool->{nicks}{lc $id_or_nick} } : undef; } # add a user to the pool. sub add_user { my ($pool, $user) = @_; return $user if exists $user->{id} && $pool->{users}{$user}; # use the next available ID. my $id = $user->{id} = $pool->_next_user_id; # weakly reference to the user. # this will be strengthened when the user is retained. $pool->{users}{$id} = $user; $pool->{ref_count}{$id} = 0; weaken($pool->{users}{$id}); # reference to the pool. $user->{pool} = $pool; # store the nickname. $pool->{nicks}{ lc $user->{nick} } = $id; # make the IRC object a listener. $user->add_listener($pool->irc, 'user'); return $user; } # remove a user from the pool. sub remove_user { my ($pool, $user) = @_; return unless $pool->{users}{$user}; delete $pool->{nicks}{ lc $user->{nick} }; delete $pool->{users}{$user}; # remove the user from channels. # this is actually done in other places and is just a harmless # double-check to prevent reference chains. if ($user->channels) { $_->remove_user($user) foreach $user->channels; } return 1; } # change a user's nickname. sub set_user_nick { my ($pool, $user, $old_nick, $nick) = @_; delete $pool->{nicks}{lc $old_nick}; $pool->{nicks}{lc $nick} = $user; } # fetch next available user ID. sub _next_user_id { my $pool = shift; $pool->{_uid} ||= 0; return $pool->irc->id.$pool->{_uid}++.q(u); } ################## ### REFERENCES ### ################## # increase reference count. sub retain { my ($pool, $obj, $comment) = @_; my $refcount = ++$pool->{ref_count}{$obj}; # add comment. if (defined $comment) { $pool->{comments}{$obj} ||= []; push @{ $pool->{comments}{$obj} }, $comment; } return $refcount if $refcount != 1; # refcount has been incremented to one. # store the object semi-permanently. # re-reference. my $type = _type_of($obj); delete $pool->{$type}{$obj}; $pool->{$type}{$obj} = $obj; return 1; } # decrease reference count. sub release { my ($pool, $obj, $comment) = @_; my $refcount = --$pool->{ref_count}{$obj}; # remove comment. if ($pool->{comments}{$obj} && defined $comment) { @{ $pool->{comments}{$obj} } = grep { $_ ne $comment } @{ $pool->{comments}{$obj} }; } return $refcount if $refcount; # refcount is zero. # we should now weaken our reference. my $type = _type_of($obj); weaken($pool->{$type}{$obj}); return 0; } # fetch reference count. sub refcount { my ($pool, $obj) = @_; return $pool->{ref_count}{$obj} || 0; } # fetch reference comments. sub references { my ($pool, $obj) = @_; return @{ $pool->{comments}{$obj} || [] }; } sub _type_of { my $obj = shift; my $type = 'objects'; $type = 'users' if $obj->isa('Evented::IRC::User'); $type = 'channels' if $obj->isa('Evented::IRC::Channel'); $type = 'servers' if $obj->isa('Evented::IRC::Server'); return $type; } 1
cooper/evented-irc
lib/Evented/IRC/Pool.pm
Perl
bsd-2-clause
6,845
# Copyrights 2013 by [Mark Overmeer]. # For other contributors see Changes. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.01. package Net::OAuth2; use vars '$VERSION'; $VERSION = '0.52'; use warnings; use strict; 1;
alanctgardner/gdrive-backup-perl
Net/OAuth2.pm
Perl
bsd-2-clause
273
print "Hello Class! This was fun\n"; exit;
VxGB111/Perl-Programming-Homework
SFBHelloclass.pl
Perl
bsd-2-clause
43
#!/usr/bin/env perl -w ############################################### # perl script to generated LTL specification and # config file to synthesize a generalized buffer # between k senders and 2 receivers. # # Usage: ./genbuf_generator.pl <num_of_senders> <fname> # # Generated files: fname # Default file name is genbuf # ############################################### use strict; use POSIX; # qw(ceil floor); sub slc { my $j = shift; my $bits = shift; my $assign = ""; my $val; for (my $bit = 0; $bit < $bits; $bit++) { $val = $j % 2; if ($val == 0){ $assign .= "!SLC$bit'"; }else{ $assign .= "SLC$bit'"; } $assign .= " & " unless ($bit == $bits-1); $j = floor($j/2); } return $assign; } ############################################### # MAIN if(! defined($ARGV[0])) { print "Usage: ./genbuf_generator.pl <num_of_senders> <prefix>\n"; exit; } my $fname = "genbuf"; if( defined($ARGV[1])) { $fname = $ARGV[1]; } #variables for LTL specification my $num_senders = $ARGV[0]; my $slc_bits = ceil((log $num_senders)/(log 2)); $slc_bits = 1 if ($slc_bits == 0); my $num_receivers = 2; my $guarantees = ""; my @assert; my $assumptions = ""; my @assume; #variables for config file my $input_vars = ""; my $output_vars = ""; my $env_initial = ""; my $sys_initial = ""; my $env_transitions = ""; my $sys_transitions = ""; my $env_fairness = ""; my $sys_fairness = ""; ############################################### # Communication with senders # my ($g, $a); for (my $i=0; $i < $num_senders; $i++) { #variable definition $input_vars .= "StoB_REQ$i\n"; $output_vars.= "BtoS_ACK$i\n"; #initial state $env_initial .= "! StoB_REQ$i\n"; $sys_initial .= "! BtoS_ACK$i\n"; $guarantees .= "\n##########################################\n"; $guarantees .= "#Guarantees for sender $i\n"; ########################################## # Guarantee 1 $g = "StoB_REQ$i -> F(BtoS_ACK$i) \n # G1\n"; $guarantees .= $g; push (@assert, $g); # Guarantee 2 $g = "(! StoB_REQ$i & StoB_REQ$i') -> (! BtoS_ACK$i') \n # G2\n"; $guarantees .= $g; push (@assert, $g); $sys_transitions .= $g; $sys_fairness .= "StoB_REQ$i <-> BtoS_ACK$i \n # G1 + G2\n"; # Guarantee 3 # $g = "G(StoB_REQ$i=0 -> (BtoS_ACK$i=1 + X(BtoS_ACK$i=0)));\t#G3\n"; $g = "(! BtoS_ACK$i & ! StoB_REQ$i) -> (! BtoS_ACK$i') \n # G2\n"; $guarantees .= $g; push (@assert, $g); $sys_transitions .= $g; # Guarantee 4 $g = "(BtoS_ACK$i & StoB_REQ$i) -> (BtoS_ACK$i') \n # G4\n"; $guarantees .= $g; push (@assert, $g); $sys_transitions .= $g; # Assumption 1 $a = "(StoB_REQ$i & ! BtoS_ACK$i) -> (StoB_REQ$i') \n # A1\n"; $assumptions .= $a; push (@assume, $a); $env_transitions .= $a; $a = "BtoS_ACK$i -> (! StoB_REQ$i') \n # A1\n"; $assumptions .= $a; push (@assume, $a); $env_transitions .= $a; # Guarantee 5 for (my $j=$i+1; $j < $num_senders; $j++) { $g = "(! BtoS_ACK$i) | (! BtoS_ACK$j) \n # G5\n"; $guarantees .= $g; push (@assert, $g); $sys_transitions .= $g; } } ############################################### # Communication with receivers # if ($num_receivers != 2) { print "Note that the DBW for Guarantee 7 works only for two receivers.\n"; exit; } for (my $j=0; $j < $num_receivers; $j++) { #variable definition $input_vars .= "RtoB_ACK$j\n"; $output_vars.= "BtoR_REQ$j\n"; #initial state $env_initial .= "! RtoB_ACK$j\n"; $sys_initial .= "! BtoR_REQ$j\n"; $guarantees .= "\n##########################################\n"; $guarantees .= "# Guarantees for receiver $j\n"; # Assumption 2 $a = "G(BtoR_REQ$j -> F(RtoB_ACK$j)) \n # A2\n"; $assumptions .= $a; push (@assume, $a); $env_fairness .= "BtoR_REQ$j <-> RtoB_ACK$j \n # A2\n"; # Assumption 3 $a = "(! BtoR_REQ$j) -> (! RtoB_ACK$j') \n # A3\n"; $assumptions .= $a; push (@assume, $a); $env_transitions .= $a; # Assumption 4 $a = "(BtoR_REQ$j & RtoB_ACK$j) -> (RtoB_ACK$j') \n # A4\n"; $assumptions .= $a; push (@assume, $a); $env_transitions .= $a; # Guarantee 6 $g = "(BtoR_REQ$j & ! RtoB_ACK$j) -> (BtoR_REQ$j') \n # G6\n"; $guarantees .= $g; push (@assert, $g); $sys_transitions .= $g; # Guarantee 7 for (my $k=$j+1; $k < $num_receivers; $k++) { $g = "(! BtoR_REQ$j) | (! BtoR_REQ$k) \n # G7\n"; $guarantees .= $g; push (@assert, $g); $sys_transitions .= $g; } # G7: rose($j) -> X (no_rose W rose($j+1 mod $num_receivers)) my $n = ($j + 1)%$num_receivers; #next my $rose_j = "( (! BtoR_REQ$j) & (BtoR_REQ$j'))"; my $nrose_j = "( BtoR_REQ$j | (! BtoR_REQ$j'))"; my $rose_n = "( (! BtoR_REQ$n) & (BtoR_REQ$n'))"; $g = "G( $rose_j ->\n X(($nrose_j U $rose_n) + \n G($nrose_j))) \n # G7\n"; $guarantees .= $g; push (@assert, $g); #construct DBW for G7 - see below # Guarantee 6 and 8 $g = "RtoB_ACK$j -> (! BtoR_REQ$j') \n # G8\n"; $guarantees .= $g; push (@assert, $g); $sys_transitions .= $g; } # DBW for guarantee 7 $output_vars .= "stateG7_0\n"; $output_vars .= "stateG7_1\n"; $sys_initial .= "! stateG7_0\n"; $sys_initial .= "stateG7_1\n"; $sys_transitions .= "(BtoR_REQ0 & BtoR_REQ1) -> FALSE \n # G7\n"; $sys_transitions .= "( (! stateG7_1) & (! BtoR_REQ0) & BtoR_REQ1) ->"; $sys_transitions .= " (stateG7_1' & (! stateG7_0') ) \n # G7\n"; $sys_transitions .= "(stateG7_1 & BtoR_REQ0 & (! BtoR_REQ1) ) ->"; $sys_transitions .= " ( (! stateG7_1') & (! stateG7_0') ) \n # G7\n"; $sys_transitions .= "( (! stateG7_1) & (! BtoR_REQ0) & (! BtoR_REQ1) ) ->"; $sys_transitions .= " ( (! stateG7_1') & stateG7_0') \n # G7\n"; $sys_transitions .= "(stateG7_1 & (! BtoR_REQ0) & (! BtoR_REQ1) ) ->"; $sys_transitions .= " (stateG7_1' & stateG7_0') \n # G7\n"; $sys_transitions .= "( (! stateG7_1) & (! stateG7_0) & BtoR_REQ0 & (! BtoR_REQ1) ) ->"; $sys_transitions .= " ( (! stateG7_1') & (! stateG7_0') ) \n # G7\n"; $sys_transitions .= "(stateG7_1 & (! stateG7_0) & (! BtoR_REQ0) & BtoR_REQ1) ->"; $sys_transitions .= " (stateG7_1' & (! stateG7_0') ) \n # G7\n"; $sys_transitions .= "( (! stateG7_1) & stateG7_0 & BtoR_REQ0) -> FALSE \n # G7\n"; $sys_transitions .= "(stateG7_1 & stateG7_0 & BtoR_REQ1) -> FALSE \n # G7\n"; ############################################### # Communication with FIFO and multiplexer # #variable definition $input_vars .= "FULL\n"; $input_vars .= "EMPTY\n"; $output_vars .= "ENQ\n"; $output_vars .= "DEQ\n"; $output_vars .= "stateG12\n"; #initial state $env_initial .= "! FULL\n"; $env_initial .= "EMPTY\n"; $sys_initial .= "! ENQ\n"; $sys_initial .= "! DEQ\n"; $sys_initial .= "! stateG12\n"; for (my $bit=0; $bit < $slc_bits; $bit++) { $output_vars .= "SLC$bit\n"; $sys_initial .= "! SLC$bit\n"; } $guarantees .= "\n##########################################\n"; $guarantees .= "# Guarantees for FIFO and multiplexer\n"; # Guarantee 9: ENQ and SLC $guarantees .= "\n##########################################\n"; $guarantees .= "# ENQ <-> Exists i: rose(BtoS_ACKi)\n"; my $roseBtoS = ""; my $roseBtoSi = ""; for (my $i=0; $i < $num_senders; $i++) { $roseBtoSi = "( (! BtoS_ACK$i) & BtoS_ACK$i')"; $g = "$roseBtoSi -> ENQ' \n # G9\n"; $guarantees .= $g; push (@assert, $g); $sys_transitions .= $g; $roseBtoS .= "(BtoS_ACK$i | (! BtoS_ACK$i'))"; $roseBtoS .= " & " if ($i < ($num_senders - 1)); if ($i == 0) { $g = "$roseBtoSi -> (".slc($i, $slc_bits).") \n # G9\n"; } else { $g = "$roseBtoSi <-> (".slc($i, $slc_bits).") \n # G9\n"; } $guarantees .= $g; push (@assert, $g); $sys_transitions .= $g; } $g = "($roseBtoS) -> ! ENQ' \n # G9\n"; $guarantees .= $g; push (@assert, $g); $sys_transitions .= $g; # Guarantee 10 $guarantees .= "\n##########################################\n"; $guarantees .= "# DEQ <-> Exists j: fell(RtoB_ACKj)\n"; my $fellRtoB = ""; for (my $j=0; $j < $num_receivers; $j++) { $g = "(RtoB_ACK$j & (! RtoB_ACK$j')) -> DEQ' \n # G10\n"; $guarantees .= $g; push (@assert, $g); $sys_transitions .= $g; $fellRtoB .= "( (! RtoB_ACK$j) | RtoB_ACK$j')"; $fellRtoB .= " & " if ($j < ($num_receivers - 1)); } $g = "($fellRtoB) -> (! DEQ') \n # G10\n"; $guarantees .= $g; push (@assert, $g); $sys_transitions .= $g; # Guarantee 11 $guarantees .= "\n"; $g = "(FULL & (! DEQ)) -> (! ENQ) \n # G11\n"; $guarantees .= $g; push (@assert, $g); $sys_transitions .= $g; $g = "EMPTY -> (! DEQ) \n # G11\n"; $guarantees .= $g; push (@assert, $g); $sys_transitions .= $g; # Guarantee 12 $g = "G( (! EMPTY) -> F(DEQ)) \n # G12\n"; $guarantees .= $g; push (@assert, $g); $sys_transitions .= "( (! stateG12) & EMPTY) -> (! stateG12') \n # G12\n"; $sys_transitions .= "( (! stateG12) & DEQ ) -> (! stateG12') \n # G12\n"; $sys_transitions .= "( (! stateG12) & (! EMPTY) & (! DEQ) ) -> stateG12' \n # G12\n"; $sys_transitions .= "(stateG12 & (! DEQ) ) -> stateG12' \n # G12\n"; $sys_transitions .= "(stateG12 & DEQ ) -> (! stateG12') \n # G12\n"; $sys_fairness .= "! stateG12 \n # G12\n"; # Assumption 4 $a = "(ENQ & (! DEQ) ) -> ! EMPTY' \n # A4\n"; $assumptions .= $a; push (@assume, $a); $env_transitions .= $a; $a = "(DEQ & (! ENQ) ) -> ! FULL' \n # A4\n"; $assumptions .= $a; push (@assume, $a); $env_transitions .= $a; $a = "(ENQ <-> DEQ) -> ((FULL <-> FULL') & (EMPTY <-> EMPTY')) \n # A4\n"; $assumptions .= $a; push (@assume, $a); $env_transitions .= $a; ############################################### # PRINT CONFIG FILE ############################################### print "Generating $fname\n"; open (CFG, ">$fname"); print CFG "###############################################\n"; print CFG "# Input variable definition\n"; print CFG "###############################################\n"; print CFG "[INPUT]\n"; print CFG $input_vars; print CFG "\n"; print CFG "###############################################\n"; print CFG "# Output variable definition\n"; print CFG "###############################################\n"; print CFG "[OUTPUT]\n"; print CFG $output_vars; print CFG "\n"; print CFG "###############################################\n"; print CFG "# Environment specification\n"; print CFG "###############################################\n"; print CFG "[ENV_INIT]\n"; print CFG $env_initial; print CFG "\n"; print CFG "[ENV_TRANS]\n"; print CFG $env_transitions; print CFG "\n"; print CFG "[ENV_LIVENESS]\n"; print CFG $env_fairness; print CFG "\n"; print CFG "###############################################\n"; print CFG "# System specification\n"; print CFG "###############################################\n"; print CFG "[SYS_INIT]\n"; print CFG $sys_initial; print CFG "\n"; print CFG "[SYS_TRANS]\n"; print CFG $sys_transitions; print CFG "\n"; print CFG "[SYS_LIVENESS]\n"; print CFG $sys_fairness; print CFG "\n"; close CFG;
johnyf/gr1experiments
examples/genbuf/genbuf_spec_generator.pl
Perl
bsd-3-clause
10,976
package WebService::Rackspace::DNS; use 5.010; use Mouse; # ABSTRACT: WebService::Rackspace::DNS - an interface to rackspace.com's RESTful Cloud DNS API using Web::API our $VERSION = '0.1'; # VERSION with 'Web::API'; has 'location' => ( is => 'rw', isa => 'Str', lazy => 1, default => sub { '' }, ); has 'commands' => ( is => 'rw', default => sub { { # needed for login() tokens => { method => 'POST', path => 'tokens', mandatory => [ 'user', 'api_key' ], wrapper => [ 'auth', 'RAX-KSKEY:apiKeyCredentials' ], }, # limits limits => { path => 'limits' }, limit_types => { path => 'limits/types' }, limit => { path => 'limits/:id' }, # domains domains => { path => 'domains' }, domain => { path => 'domains/:id' }, domain_history => { path => 'domains/:id/changes', }, zonefile => { path => 'domains/:id/export', }, create_domain => { method => 'POST', path => 'domains', mandatory => ['domains'], }, import_domain => { method => 'POST', path => 'domains/import', mandatory => ['domains'], # mandatory => [ 'contents' ], # default_attributes => { contentType => 'BIND_9' }, }, update_domain => { method => 'PUT', path => 'domains/:id', }, update_domains => { method => 'PUT', path => 'domains', mandatory => ['domains'], }, delete_domain => { method => 'DELETE', path => 'domains/:id', }, delete_domains => { method => 'DELETE', path => 'domains', mandatory => ['id'], }, subdomains => { path => 'domains/:id/subdomains', }, # records records => { path => 'domains/:id/records', }, record => { path => 'domains/:id/records/:record_id', }, create_record => { method => 'POST', path => 'domains/:id/records', }, update_record => { method => 'PUT', path => 'domains/:id/records/:record_id', }, update_records => { method => 'PUT', path => 'domains/:id/records', }, delete_record => { method => 'DELETE', path => 'domains/:id/records/:record_id', }, delete_records => { method => 'DELETE', path => 'domains/:id/records', }, # PTRs ptrs => { path => 'rdns/:id', mandatory => ['href'], }, ptr => { path => 'rdns/:id/:record_id', mandatory => ['href'], }, create_ptr => { method => 'POST', path => 'rdns', mandatory => [ 'recordsList', 'link' ], }, update_ptr => { method => 'PUT', path => 'rdns', mandatory => [ 'recordsList', 'link' ], }, delete_ptr => { method => 'DELETE', path => 'rdns/:id', mandatory => ['href'], optional => ['ip'], }, # jobs status status => { path => 'status/:id', default_attributes => { showDetails => 'true' }, }, }; }, ); sub commands { my ($self) = @_; return $self->commands; } sub login { my ($self) = @_; # rackspace uses one authentication URL for all their services my $base_url = $self->base_url; if (uc($self->location) eq 'UK') { $self->base_url('https://lon.identity.api.rackspacecloud.com/v2.0'); } else { $self->base_url('https://identity.api.rackspacecloud.com/v2.0'); } $self->debug(0); #debug my $res = $self->tokens(user => $self->user, api_key => $self->api_key); $self->debug(1); #debug # set special auth header token for future requests if (exists $res->{content}->{access}->{token}->{id}) { $self->header( { 'X-Auth-Token' => $res->{content}->{access}->{token}->{id} }); # add tenant ID to previous base_url $self->base_url( $base_url . $res->{content}->{access}->{token}->{tenant}->{id}); } return $res; } sub BUILD { my ($self) = @_; $self->user_agent(__PACKAGE__ . ' ' . $WebService::Rackspace::DNS::VERSION); $self->content_type('application/json'); # $self->extension('json'); $self->auth_type('none'); $self->mapping({ user => 'username', api_key => 'apiKey', 1 => "true", 0 => "false", email => 'emailAddress', }); if (uc($self->location) eq 'UK') { $self->base_url('https://lon.dns.api.rackspacecloud.com/v1.0/'); } else { $self->base_url('https://dns.api.rackspacecloud.com/v1.0/'); } my $res = $self->login; return $res if (exists $res->{error}); return $self; } 1; # End of WebService::Rackspace::DNS __END__ =pod =head1 NAME WebService::Rackspace::DNS - WebService::Rackspace::DNS - an interface to rackspace.com's RESTful Cloud DNS API using Web::API =head1 VERSION version 0.1 =head1 SYNOPSIS Please refer to the API documentation at L<http://docs.rackspace.com/cdns/api/v1.0/cdns-devguide/content/overview.html> use WebService::Rackspace::DNS; use Data::Dumper; my $dns = WebService::Rackspace::DNS->new( debug => 1, user => 'jsmith', api_key => 'aaaaa-bbbbb-ccccc-12345678', ); my $response = $dns->create_domain( domains => [ { name => "blablub.com", emailAddress => 'bleep@bloop.com', recordsList => { records => [ { name => "blablub.com", type => "MX", priority => 10, data => "127.0.0.1" }, { name => "ftp.blablub.com", ttl => 3600, type => "A", data => "127.0.0.1" comment => "A record for FTP server", } ], }, } ] ); print Dumper($response); $response = $dns->status(id => "some-funny-long-job-identifier"); print Dumper($response); =head1 ATTRIBUTES =head2 location =head1 SUBROUTINES/METHODS =head2 limits =head2 limit_types =head2 limit =head2 domains =head2 domain =head2 domain_history =head2 zonefile =head2 create_domain =head2 import_domain =head2 update_domain =head2 update_domains =head2 delete_domain =head2 delete_domains =head2 subdomains =head2 records =head2 record =head2 create_record =head2 update_record =head2 update_records =head2 delete_record =head2 delete_records =head2 ptrs =head2 ptr =head2 create_ptr =head2 update_ptr =head2 delete_ptr =head2 status =head1 INTERNALS =head2 login do rackspace's strange non-standard login token thing =head2 BUILD basic configuration for the client API happens usually in the BUILD method when using Web::API =head1 BUGS Please report any bugs or feature requests on GitHub's issue tracker L<https://github.com/nupfel/WebService-Rackspace-DNS/issues>. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc WebService::Rackspace::DNS You can also look for information at: =over 4 =item * GitHub repository L<https://github.com/nupfel/WebService-Rackspace-DNS> =item * MetaCPAN L<https://metacpan.org/module/WebService::Rackspace::DNS> =item * AnnoCPAN: Annotated CPAN documentation L<http://annocpan.org/dist/WebService::Rackspace::DNS> =item * CPAN Ratings L<http://cpanratings.perl.org/d/WebService::Rackspace::DNS> =back =head1 ACKNOWLEDGEMENTS =over 4 =item * Lenz Gschwendtner (@norbu09), for being an awesome mentor and friend. =back =head1 AUTHOR Tobias Kirschstein <lev@cpan.org> =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2013 by Tobias Kirschstein. This is free software, licensed under: The (three-clause) BSD License =cut
gitpan/WebService-Rackspace-DNS
lib/WebService/Rackspace/DNS.pm
Perl
bsd-3-clause
8,908
# # Net::fonolo - PERL OO interface to the fonolo developer API (http://consumer.fonolo.com) # # Copyright (c) 2011, FonCloud, Inc. # All rights reserved. # # This software is licensed under a BSD style license; see COPYING for details. # # Written by Mike Pultz (mike@mikepultz.com) # package Net::fonolo; $VERSION = "1.4"; use warnings; use strict; require HTTP::Headers; use JSON::RPC::Client; sub new { my $_class = shift; my %_conf = @_; my %values = (); # # Fonolo API RPC Host # if (defined($_conf{rpcurl})) { $values{rpcurl} = $_conf{rpcurl}; } else { $values{rpcurl} = "https://json-rpc.live.fonolo.com"; } # # Custom HTTP user agent # if (defined($_conf{useragent})) { $values{useragent} = $_conf{useragent}; } else { $values{useragent} = "Net::fonolo/$Net::fonolo::VERSION"; } # # set a developer key if it's provided # if (defined($_conf{key})) { if ($_conf{key} =~ /^[a-zA-Z0-9]{32}$/) { $values{key} = $_conf{key}; } } # # set auth info if it's provided # if ( (defined($_conf{username})) && (defined($_conf{password})) ) { $values{username} = $_conf{username}; $values{password} = $_conf{password}; } # # create the JSON::RPC::Client object # $values{client} = new JSON::RPC::Client; return bless {%values}, $_class; } # # set a developer key # sub set_key { my ($_self, $_key) = @_; if (defined($_key)) { if ($_key =~ /^[a-zA-Z0-9]{32}$/) { $_self->{key} = $_key; } } } # # set a username/password for authentication # sub set_auth { my ($_self, $_username, $_password) = @_; if ( (defined($_username)) && (defined($_password)) ) { $_self->{username} = $_username; $_self->{password} = $_password; } } # # send a auth request # sub _send_request { my ($_self, $_obj) = @_; # # set the developer key header # $_self->{client}->ua()->default_headers()->header('X-Fonolo-Auth' => $_self->{key}); # # set the username/password headers # $_self->{client}->ua()->default_headers()->header('X-Fonolo-Username' => $_self->{username}); $_self->{client}->ua()->default_headers()->header('X-Fonolo-Password' => $_self->{password}); # # set the useragent header # $_self->{client}->ua()->agent($_self->{useragent}); # # execute the request # my $res = $_self->{client}->call($_self->{rpcurl}, $_obj); if (defined($res->{content}->{result})) { return $res->{content}->{result}; } else { return undef; } } # # deprecated (renamed) functions # sub lookup_company { return company_details(@_); } sub list_companies { return company_list(@_); } sub search_companies { return company_search(@_); } # # API functions # sub get_error { my ($_self) = @_; my $obj = { method => 'garbage' }; my $res = _send_request($_self, $obj); return _send_request($_self, $obj); } sub get_version { my ($_self) = @_; my $obj = { method => 'system.describe' }; if (!defined($_self->{key})) { $_self->{key} = '000000000000000000000000000000'; } my $res = _send_request($_self, $obj); if ($_self->{key} eq '000000000000000000000000000000') { delete($_self->{key}); } if (defined($res->{version})) { return $res->{version}; } else { return undef; } } sub check_member { my ($_self) = @_; my $obj = { method => 'check_member', params => [$_self->{username}, $_self->{password}] }; return _send_request($_self, $obj); } sub check_member_number { my ($_self, $_number) = @_; my $obj = { method => 'check_member', params => [$_self->{username}, $_self->{password}, $_number] }; return _send_request($_self, $obj); } sub company_search { my ($_self, $_search) = @_; my $obj = { method => 'company_search', params => [$_search] }; return _send_request($_self, $obj); } sub company_list { my ($_self, $_limit, $_page, $_date_since) = @_; my $obj = { method => 'company_list', params => [$_limit, $_page, $_date_since] }; return _send_request($_self, $obj); } sub company_details { my ($_self, $_company) = @_; my $obj = { method => 'company_details', params => [$_company] }; return _send_request($_self, $obj); } sub call_start { my ($_self, $_company, $_number) = @_; my $obj = { method => 'call_start', params => [$_company, $_number] }; return _send_request($_self, $obj); } sub call_cancel { my ($_self, $_call_id) = @_; my $obj = { method => 'call_cancel', params => [$_call_id] }; return _send_request($_self, $obj); } sub call_status { my ($_self, $_call_id) = @_; my $obj = { method => 'call_status', params => [$_call_id] }; return _send_request($_self, $obj); } 1; __END__ =head1 NAME Net::fonolo - Perl interface to fonolo (http://consumer.fonolo.com) =head1 VERSION This document describes Net::fonolo version 1.4 =head1 SYNOPSIS #!/usr/bin/perl use Net::fonolo; my $fonolo = Net::fonolo->new( key => "< your fonolo developer API key >", username => "< a fonolo member username >", password => "< a fonolo member password >" ); my $result = $fonolo->search_companies("air canada"); ... =head1 DESCRIPTION =over =item new(...) You must supply a hash containing the configuration for the connection. Valid configuration items are: =over =item C<key> Your fonolo.com API developer key. You can get a developer key by signing up fro the fonolo developer program from the accounts tab of your fonolo.com account. REQUIRED. =item C<username> Username of the account at fonolo.com. This is usually your email address. REQUIRED. =item C<password> Password of your account at fonolo. REQUIRED. =item C<useragent> OPTIONAL: Sets the User Agent header in the HTTP request. If omitted, this will default to "Net::fonolo/$Net::fonolo::VERSION" =back =item set_key($api_developer_key Change the fonolo developer API key for sending API requests. $api_developer_key is the 32 byte API key, listed on the projects page for your application. =item set_auth($username, $password Change the username/password for logging into fonolo.com. This is helpful when managing multiple accounts. $username is the fonolo.com username (e-mail address) of the client account. $password is the plain-text password or the client account. =back =head2 SYSTEM FUNCTIONS =over =item get_version Return the current fonolo.com RPC server version =back =head2 MEMBER FUNCTIONS =over =item check_member Validates the current username/password, set by the new or set_auth methods. =item check_member_number($phone_number) Validates that the given phone number belongs to the current username/password, and that it's active. "Deep Dial" requests can only be made to numbers that are currently configured on the given fonolo.com account. $phone_number is the phone number to validated, formatted as XXX-YYY-ZZZZ. This value can also be a SIP address in the format: sip:XXX@YYY =back =head2 COMPANY FUNCTIONS =over =item company_search($search_string) Perform a search against the fonolo.com database for the given search string. $search_string can be either a free-form keyword to search, or a company phone number, formated as XXX-YYY-ZZZZ. =item company_list =item company_list($limit) =item company_list($limit, $page) =item company_list($limit, $page, $date_since) Returns a list of all the companies in the fonolo.com database. $limit is how many results to return per page; this defaults to 25. $page is the page number starting with 0; this defaults to 0 (the first page) $date_since is a date (formatted as YYYY-MM-DD); if this date is included, then only companies with updates newer than this date are returned in the result set. If it's not included, then all results are returned. This is helpful for situations where you want to cache the company list on the application side, and then get incremental updates each time the application is started. =item company_details($company_id) Lookup specific information about the given company id. $company_id is the 32 byte company id, returned by the company_list or company_search methods. =back =head2 DEEP DIAL FUNCTIONS =over =item call_start($company_id, $phone_number) Start a "Deep Dial" request to the given company_id and phone_number. This phone_number must pass validation through the check_member_number method. $company_id is the 32 byte company id returned by the company_* functions above. $phone_number is the phone number to call-back, formatted as XXX-YYY-ZZZZ. =item call_cancel($call_id) Cancel a call that was previously started by the call_start method. $call_id is the call id returned by the call_start method. =item call_status($call_id) Return the current call status of the call referenced by the $call_id. $call_id is the call id returned by the call_start method. =back =head2 DEPRECATED FUNCTIONS =over =item search_companies see company_search above =item list_companies see company_list above =item lookup_company see company_details above =back =head1 BUGS AND LIMITATIONS No bugs have been reported. Please report any bugs or feature requests to C<bug-net-fonolo@rt.cpan.org>, or through the web interface at L<http://rt.cpan.org>. =head1 AUTHOR Mike Pultz <mike@mikepultz.com> =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
gitpan/Net-fonolo
lib/Net/fonolo.pm
Perl
bsd-3-clause
10,562
#!/pkg/gnu/bin//perl5 # #$Id: WebStone-manage.pl 80826 2008-03-04 14:51:23Z wotte $ # push(@INC, "$wd/bin"); require('WebStone-common.pl'); html_begin("Administration"); $runsdir = "$wd/bin/runs"; $thelength = length($runsdir) + 10; $oldrunsdir = $runsdir; $oldfilelist = "$wd/conf/filelist"; print CLIENT <<EOF <FORM METHOD="POST" ACTION="$wd/bin/killbench.pl"> <H3>Clean up stray WebStone processes</H3> <INPUT TYPE="SUBMIT" VALUE="Kill"> </FORM> <HR> <FORM METHOD="POST" ACTION="$wd/bin/move-runs.pl"> <H3>Move Results Directory to:</H3> <INPUT TYPE=TEXT NAME=runsdir SIZE=$thelength VALUE=$runsdir> <INPUT TYPE="SUBMIT" VALUE="Move Directory"> </FORM> EOF ; html_end(); # end
batmancn/TinySDNController
ACE_wrappers/apps/JAWS/clients/WebSTONE/bin/WebStone-manage.pl
Perl
apache-2.0
691
# # 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::fujitsu::eternus::dx::ssh::mode::cpu; use base qw(centreon::plugins::mode); use strict; use warnings; use centreon::plugins::values; my $maps_counters = { cpu => { '001_usage' => { set => { key_values => [ { name => 'usage' }, { name => 'display' } ], output_template => 'Usage : %d %%', perfdatas => [ { label => 'cpu', value => 'usage_absolute', template => '%d', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, ], }, }, } }; 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' }, "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 }, "command:s" => { name => 'command', default => 'show' }, "command-path:s" => { name => 'command_path' }, "command-options:s" => { name => 'command_options', default => 'performance -type cm' }, "no-component:s" => { name => 'no_component' }, "filter-name:s" => { name => 'filter_name' }, }); $self->{no_components} = undef; foreach my $key (('cpu')) { foreach (keys %{$maps_counters->{$key}}) { my ($id, $name) = split /_/; if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) { $options{options}->add_options(arguments => { 'warning-' . $name . ':s' => { name => 'warning-' . $name }, 'critical-' . $name . ':s' => { name => 'critical-' . $name }, }); } $maps_counters->{$key}->{$_}->{obj} = centreon::plugins::values->new(output => $self->{output}, perfdata => $self->{perfdata}, label => $name); $maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}}); } } return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') { $self->{option_results}->{remote} = 1; } foreach my $key (('cpu')) { foreach (keys %{$maps_counters->{$key}}) { $maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results}); } } if (defined($self->{option_results}->{no_component})) { if ($self->{option_results}->{no_component} ne '') { $self->{no_components} = $self->{option_results}->{no_component}; } else { $self->{no_components} = 'critical'; } } } sub run { my ($self, %options) = @_; $self->manage_selection(); my $multiple = 1; if (scalar(keys %{$self->{cpu}}) == 1) { $multiple = 0; } if ($multiple == 1) { $self->{output}->output_add(severity => 'OK', short_msg => 'All CPUs are ok'); } foreach my $id (sort keys %{$self->{cpu}}) { my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); my @exits = (); foreach (sort keys %{$maps_counters->{cpu}}) { my $obj = $maps_counters->{cpu}->{$_}->{obj}; $obj->set(instance => $id); my ($value_check) = $obj->execute(values => $self->{cpu}->{$id}); if ($value_check != 0) { $long_msg .= $long_msg_append . $obj->output_error(); $long_msg_append = ', '; next; } my $exit2 = $obj->threshold_check(); push @exits, $exit2; my $output = $obj->output(); $long_msg .= $long_msg_append . $output; $long_msg_append = ', '; if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) { $short_msg .= $short_msg_append . $output; $short_msg_append = ', '; } $obj->perfdata(extra_instance => $multiple); } $self->{output}->output_add(long_msg => "CPU '$self->{cpu}->{$id}->{display}' $long_msg"); my $exit = $self->{output}->get_most_critical(status => [ @exits ]); if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) { $self->{output}->output_add(severity => $exit, short_msg => "CPU '$self->{cpu}->{$id}->{display}' $short_msg" ); } if ($multiple == 0) { $self->{output}->output_add(short_msg => "CPU '$self->{cpu}->{$id}->{display}' $long_msg"); } } $self->{output}->display(); $self->{output}->exit(); } sub manage_selection { my ($self, %options) = @_; my $stdout = centreon::plugins::misc::execute(output => $self->{output}, options => $self->{option_results}, ssh_pipe => 1, command => $self->{option_results}->{command}, command_path => $self->{option_results}->{command_path}, command_options => $self->{option_results}->{command_options}); # Can have 4 columns also. #Location Busy Rate(%) Copy Residual Quantity(MB) #--------------------- ------------ -------------------------- #CM#0 56 55191552 #CM#0 CPU Core#0 66 - #CM#0 CPU Core#1 46 - #CM#1 52 55191552 #CM#1 CPU Core#0 62 - #CM#1 CPU Core#1 42 - $self->{cpu} = {}; foreach (split /\n/, $stdout) { next if ($_ !~ /^(CM.*?)\s{2,}(\d+)\s+\S+/); my ($cpu_name, $cpu_value) = ($1, $2); if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $cpu_name !~ /$self->{option_results}->{filter_name}/) { $self->{output}->output_add(long_msg => "Skipping '" . $cpu_name . "': no matching filter name."); next; } $self->{cpu}->{$cpu_name} = { display => $cpu_name, usage => $cpu_value }; } if (scalar(keys %{$self->{cpu}}) <= 0) { $self->{output}->output_add(severity => defined($self->{no_components}) ? $self->{no_components} : 'unknown', short_msg => 'No components are checked.'); } } 1; __END__ =head1 MODE Check CPUs usage. =over 8 =item B<--hostname> Hostname to query. =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<--command> Command to get information (Default: 'show'). Can be changed if you have output in a file. =item B<--command-path> Command path (Default: none). =item B<--command-options> Command options (Default: 'performance -type cm'). =item B<--no-component> Set the threshold where no components (Default: 'unknown' returns). =item B<--filter-name> Filter by name (regexp can be used). =item B<--warning-usage> Threshold warning (in percent). =item B<--critical-usage> Threshold critical (in percent). =back =cut
bcournaud/centreon-plugins
storage/fujitsu/eternus/dx/ssh/mode/cpu.pm
Perl
apache-2.0
9,587
sub usage { my $script = shift; print <<"END"; Usage: perl $script [--with-apache2=C:\Path\to\Apache2] perl $script --help Options: --with-apache2=C:\Path\to\Apache2 : specify the top-level Apache2 directory --help : print this help message With no options specified, an attempt will be made to find a suitable Apache2 directory. END exit; } sub check { my $apache = shift; die qq{No libhttpd library found under $apache/lib} unless -e qq{$apache/lib/libhttpd.lib}; die qq{No httpd header found under $apache/include} unless -e qq{$apache/include/httpd.h}; my $vers = qx{"$apache/bin/Apache.exe" -v}; die qq{"$apache" does not appear to be version 2.0} unless $vers =~ m!Apache/2.0!; return 1; } 1;
oerdnj/rapache
libapreq2/win32/util.pl
Perl
apache-2.0
807
package Google::Ads::AdWords::v201406::Bids; use strict; use warnings; __PACKAGE__->_set_element_form_qualified(1); sub get_xmlns { 'https://adwords.google.com/api/adwords/cm/v201406' }; our $XML_ATTRIBUTE_CLASS; undef $XML_ATTRIBUTE_CLASS; sub __get_attr_class { return $XML_ATTRIBUTE_CLASS; } use Class::Std::Fast::Storable constructor => 'none'; use base qw(Google::Ads::SOAP::Typelib::ComplexType); { # BLOCK to scope variables my %Bids__Type_of :ATTR(:get<Bids__Type>); __PACKAGE__->_factory( [ qw( Bids__Type ) ], { 'Bids__Type' => \%Bids__Type_of, }, { 'Bids__Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', }, { 'Bids__Type' => 'Bids.Type', } ); } # end BLOCK 1; =pod =head1 NAME Google::Ads::AdWords::v201406::Bids =head1 DESCRIPTION Perl data type class for the XML Schema defined complexType Bids from the namespace https://adwords.google.com/api/adwords/cm/v201406. Base class for all bids. =head2 PROPERTIES The following properties may be accessed using get_PROPERTY / set_PROPERTY methods: =over =item * Bids__Type Note: The name of this property has been altered, because it didn't match perl's notion of variable/subroutine names. The altered name is used in perl code only, XML output uses the original name: Bids.Type =back =head1 METHODS =head2 new Constructor. The following data structure may be passed to new(): =head1 AUTHOR Generated by SOAP::WSDL =cut
gitpan/GOOGLE-ADWORDS-PERL-CLIENT
lib/Google/Ads/AdWords/v201406/Bids.pm
Perl
apache-2.0
1,505
#!/usr/bin/env perl ###################################################################### # Copyright (c) 2012, Yahoo! Inc. All rights reserved. # # This program is free software. You may copy or redistribute it under # the same terms as Perl itself. Please see the LICENSE.Artistic file # included with this project for the terms of the Artistic License # under which this project is licensed. ###################################################################### use warnings; use strict; use POSIX; use File::Basename; use File::Path; use HTTP::Daemon; use HTTP::Status; use HTTP::Response; my $d = HTTP::Daemon->new( LocalAddr => "127.0.0.1", ReuseAddr => 1, ) || die "Daemon: $!"; my $url = $d->url; $url =~ s{//[^:]+:(\d+)/$}{//127.0.0.1:$1}; print $url; my $child_ok = 0; $SIG{HUP} = sub { $child_ok++ }; my $ppid = $$; if( my $pid = fork() ) { # parent writes out child pid and waits for child to signal us # that is is up and running open PID, ">./httpd.pid" or die "Failed to open ./httpd.pid: $!"; print PID $pid; close PID; while( !$child_ok ) { sleep 1; } exit 0; } else { # child daemonizes now mkpath("./http/logs", 0, 0755) unless -d "./http/logs"; close STDOUT; open STDOUT, ">>./http/logs/output.$$.log"; $|++; # autoflush close STDIN; close STDERR; open STDERR, ">>./http/logs/output.$$.log"; POSIX::setsid(); # HUP parent to let them know we are done kill 'HUP', $ppid; } $SIG{ALRM} = sub { die "httpd lived to long" }; # only live for 15m alarm(60 * 15); my $counter = 0; while (my $c = $d->accept) { my $r = $c->get_request(); my $path = $r->uri->path; my $meth = lc $r->method; open REQ, ">>./http/requests/$counter" or die "Failed to open ./http/requests/$counter: $!"; my $req = $r->as_string(); my $host = URI->new($url)->host_port; $req =~ s/$host/%{HOSTNAME}/g; print REQ $req; close REQ; if( $meth eq 'get' && $path =~ m{^/error/(\d+)} ) { my $resp = HTTP::Response->new($1); $resp->header("Connection", "close"); my $file = "./http/$meth/$path"; if( -f $file ) { my $content = do { local undef $/; open my $file, "<$file" or die "$file: $!"; <$file>; }; $resp->content($content); } else { $resp->content("ERROR"); } $c->send_response( $resp ); } elsif ( -f "./http/$meth/$path" ) { $c->send_file_response("./http/$meth/$path"); } elsif( $meth eq 'post' || $meth eq 'put' ) { my $resp = HTTP::Response->new(200); $resp->header("Connection", "close"); $resp->content( "OK"); $c->send_response( $resp ); } elsif ($meth eq 'get' and $path =~ m{^/curse} ) { my $resp = HTTP::Response->new(200); $resp->header("Content-Type", "text/x-clamation"); $resp->header("Content-Language", "en_US"); $resp->header("Connection", "close"); $resp->content( "Dammit, I'm mad!"); $c->send_response( $resp ); } elsif ($meth eq 'get' and $path =~ m{^/sleep/(\d+)} ) { my $sleep = $1; $c->send_status_line; $c->send_basic_header; $c->send_header("Connection", "close"); $c->send_crlf; select $c; $|++; select STDOUT; print $c "content\n"; sleep $sleep; print $c "content\n"; } elsif ($meth eq 'get' and $path =~ m{^/cookies} ) { my $sleep = $1; $c->send_status_line; $c->send_basic_header; $c->send_header("Set-Cookie" => "cook1=val1"); $c->send_header("Set-Cookie" => "cook2=val2; Domain=127.0.0.1; Path=/"); $c->send_header("Set-Cookie" => "cook3=val3; Expires=Mon, 18-Jan-2037 00:00:01 GMT"); $c->send_crlf; select $c; $|++; select STDOUT; print $c "content\n"; sleep $sleep; print $c "content\n"; } else { $c->send_error(RC_FORBIDDEN) } $c->close; undef($c); $counter++; }
getgearbox/gearbox
gearbox/t/core/httpd.pl
Perl
bsd-3-clause
4,170
% Frame number: 0 holdsAt( orientation( grp_ID0 )=59, 0 ). holdsAt( appearance( grp_ID0 )=appear, 0 ). % Frame number: 1 holdsAt( orientation( grp_ID0 )=65, 40 ). holdsAt( appearance( grp_ID0 )=visible, 40 ). % Frame number: 2 holdsAt( orientation( grp_ID0 )=61, 80 ). holdsAt( appearance( grp_ID0 )=visible, 80 ). % Frame number: 3 holdsAt( orientation( grp_ID0 )=61, 120 ). holdsAt( appearance( grp_ID0 )=visible, 120 ). % Frame number: 4 holdsAt( orientation( grp_ID0 )=61, 160 ). holdsAt( appearance( grp_ID0 )=visible, 160 ). % Frame number: 5 holdsAt( orientation( grp_ID0 )=61, 200 ). holdsAt( appearance( grp_ID0 )=visible, 200 ). % Frame number: 6 holdsAt( orientation( grp_ID0 )=61, 240 ). holdsAt( appearance( grp_ID0 )=visible, 240 ). % Frame number: 7 holdsAt( orientation( grp_ID0 )=61, 280 ). holdsAt( appearance( grp_ID0 )=visible, 280 ). % Frame number: 8 holdsAt( orientation( grp_ID0 )=61, 320 ). holdsAt( appearance( grp_ID0 )=visible, 320 ). % Frame number: 9 holdsAt( orientation( grp_ID0 )=61, 360 ). holdsAt( appearance( grp_ID0 )=visible, 360 ). % Frame number: 10 holdsAt( orientation( grp_ID0 )=61, 400 ). holdsAt( appearance( grp_ID0 )=visible, 400 ). % Frame number: 11 holdsAt( orientation( grp_ID0 )=61, 440 ). holdsAt( appearance( grp_ID0 )=visible, 440 ). % Frame number: 12 holdsAt( orientation( grp_ID0 )=61, 480 ). holdsAt( appearance( grp_ID0 )=visible, 480 ). % Frame number: 13 holdsAt( orientation( grp_ID0 )=61, 520 ). holdsAt( appearance( grp_ID0 )=visible, 520 ). % Frame number: 14 holdsAt( orientation( grp_ID0 )=61, 560 ). holdsAt( appearance( grp_ID0 )=visible, 560 ). % Frame number: 15 holdsAt( orientation( grp_ID0 )=61, 600 ). holdsAt( appearance( grp_ID0 )=visible, 600 ). % Frame number: 16 holdsAt( orientation( grp_ID0 )=61, 640 ). holdsAt( appearance( grp_ID0 )=visible, 640 ). % Frame number: 17 holdsAt( orientation( grp_ID0 )=61, 680 ). holdsAt( appearance( grp_ID0 )=visible, 680 ). % Frame number: 18 holdsAt( orientation( grp_ID0 )=61, 720 ). holdsAt( appearance( grp_ID0 )=visible, 720 ). % Frame number: 19 holdsAt( orientation( grp_ID0 )=61, 760 ). holdsAt( appearance( grp_ID0 )=visible, 760 ). % Frame number: 20 holdsAt( orientation( grp_ID0 )=61, 800 ). holdsAt( appearance( grp_ID0 )=visible, 800 ). % Frame number: 21 holdsAt( orientation( grp_ID0 )=61, 840 ). holdsAt( appearance( grp_ID0 )=visible, 840 ). % Frame number: 22 holdsAt( orientation( grp_ID0 )=57, 880 ). holdsAt( appearance( grp_ID0 )=visible, 880 ). % Frame number: 23 holdsAt( orientation( grp_ID0 )=57, 920 ). holdsAt( appearance( grp_ID0 )=visible, 920 ). % Frame number: 24 holdsAt( orientation( grp_ID0 )=57, 960 ). holdsAt( appearance( grp_ID0 )=visible, 960 ). % Frame number: 25 holdsAt( orientation( grp_ID0 )=57, 1000 ). holdsAt( appearance( grp_ID0 )=visible, 1000 ). % Frame number: 26 holdsAt( orientation( grp_ID0 )=57, 1040 ). holdsAt( appearance( grp_ID0 )=visible, 1040 ). % Frame number: 27 holdsAt( orientation( grp_ID0 )=57, 1080 ). holdsAt( appearance( grp_ID0 )=visible, 1080 ). % Frame number: 28 holdsAt( orientation( grp_ID0 )=57, 1120 ). holdsAt( appearance( grp_ID0 )=visible, 1120 ). % Frame number: 29 holdsAt( orientation( grp_ID0 )=57, 1160 ). holdsAt( appearance( grp_ID0 )=visible, 1160 ). % Frame number: 30 holdsAt( orientation( grp_ID0 )=57, 1200 ). holdsAt( appearance( grp_ID0 )=visible, 1200 ). % Frame number: 31 holdsAt( orientation( grp_ID0 )=57, 1240 ). holdsAt( appearance( grp_ID0 )=visible, 1240 ). % Frame number: 32 holdsAt( orientation( grp_ID0 )=57, 1280 ). holdsAt( appearance( grp_ID0 )=visible, 1280 ). % Frame number: 33 holdsAt( orientation( grp_ID0 )=57, 1320 ). holdsAt( appearance( grp_ID0 )=visible, 1320 ). % Frame number: 34 holdsAt( orientation( grp_ID0 )=57, 1360 ). holdsAt( appearance( grp_ID0 )=visible, 1360 ). % Frame number: 35 holdsAt( orientation( grp_ID0 )=57, 1400 ). holdsAt( appearance( grp_ID0 )=visible, 1400 ). % Frame number: 36 holdsAt( orientation( grp_ID0 )=57, 1440 ). holdsAt( appearance( grp_ID0 )=visible, 1440 ). % Frame number: 37 holdsAt( orientation( grp_ID0 )=57, 1480 ). holdsAt( appearance( grp_ID0 )=visible, 1480 ). % Frame number: 38 holdsAt( orientation( grp_ID0 )=57, 1520 ). holdsAt( appearance( grp_ID0 )=visible, 1520 ). % Frame number: 39 holdsAt( orientation( grp_ID0 )=57, 1560 ). holdsAt( appearance( grp_ID0 )=visible, 1560 ). % Frame number: 40 holdsAt( orientation( grp_ID0 )=57, 1600 ). holdsAt( appearance( grp_ID0 )=visible, 1600 ). % Frame number: 41 holdsAt( orientation( grp_ID0 )=57, 1640 ). holdsAt( appearance( grp_ID0 )=visible, 1640 ). % Frame number: 42 holdsAt( orientation( grp_ID0 )=57, 1680 ). holdsAt( appearance( grp_ID0 )=visible, 1680 ). % Frame number: 43 holdsAt( orientation( grp_ID0 )=57, 1720 ). holdsAt( appearance( grp_ID0 )=visible, 1720 ). % Frame number: 44 holdsAt( orientation( grp_ID0 )=57, 1760 ). holdsAt( appearance( grp_ID0 )=visible, 1760 ). % Frame number: 45 holdsAt( orientation( grp_ID0 )=57, 1800 ). holdsAt( appearance( grp_ID0 )=visible, 1800 ). % Frame number: 46 holdsAt( orientation( grp_ID0 )=57, 1840 ). holdsAt( appearance( grp_ID0 )=visible, 1840 ). % Frame number: 47 holdsAt( orientation( grp_ID0 )=57, 1880 ). holdsAt( appearance( grp_ID0 )=visible, 1880 ). % Frame number: 48 holdsAt( orientation( grp_ID0 )=57, 1920 ). holdsAt( appearance( grp_ID0 )=visible, 1920 ). % Frame number: 49 holdsAt( orientation( grp_ID0 )=57, 1960 ). holdsAt( appearance( grp_ID0 )=visible, 1960 ). % Frame number: 50 holdsAt( orientation( grp_ID0 )=57, 2000 ). holdsAt( appearance( grp_ID0 )=visible, 2000 ). % Frame number: 51 holdsAt( orientation( grp_ID0 )=57, 2040 ). holdsAt( appearance( grp_ID0 )=visible, 2040 ). % Frame number: 52 holdsAt( orientation( grp_ID0 )=57, 2080 ). holdsAt( appearance( grp_ID0 )=visible, 2080 ). % Frame number: 53 holdsAt( orientation( grp_ID0 )=57, 2120 ). holdsAt( appearance( grp_ID0 )=visible, 2120 ). % Frame number: 54 holdsAt( orientation( grp_ID0 )=57, 2160 ). holdsAt( appearance( grp_ID0 )=visible, 2160 ). % Frame number: 55 holdsAt( orientation( grp_ID0 )=57, 2200 ). holdsAt( appearance( grp_ID0 )=visible, 2200 ). % Frame number: 56 holdsAt( orientation( grp_ID0 )=57, 2240 ). holdsAt( appearance( grp_ID0 )=visible, 2240 ). % Frame number: 57 holdsAt( orientation( grp_ID0 )=57, 2280 ). holdsAt( appearance( grp_ID0 )=visible, 2280 ). % Frame number: 58 holdsAt( orientation( grp_ID0 )=57, 2320 ). holdsAt( appearance( grp_ID0 )=visible, 2320 ). % Frame number: 59 holdsAt( orientation( grp_ID0 )=57, 2360 ). holdsAt( appearance( grp_ID0 )=visible, 2360 ). % Frame number: 60 holdsAt( orientation( grp_ID0 )=57, 2400 ). holdsAt( appearance( grp_ID0 )=visible, 2400 ). % Frame number: 61 holdsAt( orientation( grp_ID0 )=57, 2440 ). holdsAt( appearance( grp_ID0 )=visible, 2440 ). % Frame number: 62 holdsAt( orientation( grp_ID0 )=57, 2480 ). holdsAt( appearance( grp_ID0 )=visible, 2480 ). % Frame number: 63 holdsAt( orientation( grp_ID0 )=57, 2520 ). holdsAt( appearance( grp_ID0 )=visible, 2520 ). % Frame number: 64 holdsAt( orientation( grp_ID0 )=57, 2560 ). holdsAt( appearance( grp_ID0 )=visible, 2560 ). % Frame number: 65 holdsAt( orientation( grp_ID0 )=57, 2600 ). holdsAt( appearance( grp_ID0 )=visible, 2600 ). % Frame number: 66 holdsAt( orientation( grp_ID0 )=57, 2640 ). holdsAt( appearance( grp_ID0 )=visible, 2640 ). % Frame number: 67 holdsAt( orientation( grp_ID0 )=57, 2680 ). holdsAt( appearance( grp_ID0 )=visible, 2680 ). % Frame number: 68 holdsAt( orientation( grp_ID0 )=57, 2720 ). holdsAt( appearance( grp_ID0 )=visible, 2720 ). % Frame number: 69 holdsAt( orientation( grp_ID0 )=57, 2760 ). holdsAt( appearance( grp_ID0 )=visible, 2760 ). % Frame number: 70 holdsAt( orientation( grp_ID0 )=57, 2800 ). holdsAt( appearance( grp_ID0 )=visible, 2800 ). % Frame number: 71 holdsAt( orientation( grp_ID0 )=57, 2840 ). holdsAt( appearance( grp_ID0 )=visible, 2840 ). % Frame number: 72 holdsAt( orientation( grp_ID0 )=57, 2880 ). holdsAt( appearance( grp_ID0 )=visible, 2880 ). % Frame number: 73 holdsAt( orientation( grp_ID0 )=57, 2920 ). holdsAt( appearance( grp_ID0 )=visible, 2920 ). % Frame number: 74 holdsAt( orientation( grp_ID0 )=57, 2960 ). holdsAt( appearance( grp_ID0 )=visible, 2960 ). % Frame number: 75 holdsAt( orientation( grp_ID0 )=57, 3000 ). holdsAt( appearance( grp_ID0 )=visible, 3000 ). % Frame number: 76 holdsAt( orientation( grp_ID0 )=57, 3040 ). holdsAt( appearance( grp_ID0 )=visible, 3040 ). % Frame number: 77 holdsAt( orientation( grp_ID0 )=57, 3080 ). holdsAt( appearance( grp_ID0 )=visible, 3080 ). % Frame number: 78 holdsAt( orientation( grp_ID0 )=57, 3120 ). holdsAt( appearance( grp_ID0 )=visible, 3120 ). % Frame number: 79 holdsAt( orientation( grp_ID0 )=57, 3160 ). holdsAt( appearance( grp_ID0 )=visible, 3160 ). % Frame number: 80 holdsAt( orientation( grp_ID0 )=57, 3200 ). holdsAt( appearance( grp_ID0 )=visible, 3200 ). % Frame number: 81 holdsAt( orientation( grp_ID0 )=57, 3240 ). holdsAt( appearance( grp_ID0 )=visible, 3240 ). % Frame number: 82 holdsAt( orientation( grp_ID0 )=57, 3280 ). holdsAt( appearance( grp_ID0 )=visible, 3280 ). % Frame number: 83 holdsAt( orientation( grp_ID0 )=57, 3320 ). holdsAt( appearance( grp_ID0 )=visible, 3320 ). % Frame number: 84 holdsAt( orientation( grp_ID0 )=57, 3360 ). holdsAt( appearance( grp_ID0 )=visible, 3360 ). % Frame number: 85 holdsAt( orientation( grp_ID0 )=57, 3400 ). holdsAt( appearance( grp_ID0 )=visible, 3400 ). % Frame number: 86 holdsAt( orientation( grp_ID0 )=57, 3440 ). holdsAt( appearance( grp_ID0 )=visible, 3440 ). % Frame number: 87 holdsAt( orientation( grp_ID0 )=57, 3480 ). holdsAt( appearance( grp_ID0 )=visible, 3480 ). % Frame number: 88 holdsAt( orientation( grp_ID0 )=57, 3520 ). holdsAt( appearance( grp_ID0 )=visible, 3520 ). % Frame number: 89 holdsAt( orientation( grp_ID0 )=57, 3560 ). holdsAt( appearance( grp_ID0 )=visible, 3560 ). % Frame number: 90 holdsAt( orientation( grp_ID0 )=57, 3600 ). holdsAt( appearance( grp_ID0 )=visible, 3600 ). % Frame number: 91 holdsAt( orientation( grp_ID0 )=57, 3640 ). holdsAt( appearance( grp_ID0 )=visible, 3640 ). % Frame number: 92 holdsAt( orientation( grp_ID0 )=57, 3680 ). holdsAt( appearance( grp_ID0 )=visible, 3680 ). % Frame number: 93 holdsAt( orientation( grp_ID0 )=57, 3720 ). holdsAt( appearance( grp_ID0 )=visible, 3720 ). % Frame number: 94 holdsAt( orientation( grp_ID0 )=57, 3760 ). holdsAt( appearance( grp_ID0 )=visible, 3760 ). % Frame number: 95 holdsAt( orientation( grp_ID0 )=57, 3800 ). holdsAt( appearance( grp_ID0 )=visible, 3800 ). % Frame number: 96 holdsAt( orientation( grp_ID0 )=57, 3840 ). holdsAt( appearance( grp_ID0 )=visible, 3840 ). % Frame number: 97 holdsAt( orientation( grp_ID0 )=57, 3880 ). holdsAt( appearance( grp_ID0 )=visible, 3880 ). % Frame number: 98 holdsAt( orientation( grp_ID0 )=57, 3920 ). holdsAt( appearance( grp_ID0 )=visible, 3920 ). % Frame number: 99 holdsAt( orientation( grp_ID0 )=57, 3960 ). holdsAt( appearance( grp_ID0 )=visible, 3960 ). % Frame number: 100 holdsAt( orientation( grp_ID0 )=57, 4000 ). holdsAt( appearance( grp_ID0 )=visible, 4000 ). % Frame number: 101 holdsAt( orientation( grp_ID0 )=57, 4040 ). holdsAt( appearance( grp_ID0 )=visible, 4040 ). % Frame number: 102 holdsAt( orientation( grp_ID0 )=57, 4080 ). holdsAt( appearance( grp_ID0 )=visible, 4080 ). % Frame number: 103 holdsAt( orientation( grp_ID0 )=57, 4120 ). holdsAt( appearance( grp_ID0 )=visible, 4120 ). % Frame number: 104 holdsAt( orientation( grp_ID0 )=57, 4160 ). holdsAt( appearance( grp_ID0 )=visible, 4160 ). % Frame number: 105 holdsAt( orientation( grp_ID0 )=57, 4200 ). holdsAt( appearance( grp_ID0 )=visible, 4200 ). % Frame number: 106 holdsAt( orientation( grp_ID0 )=57, 4240 ). holdsAt( appearance( grp_ID0 )=visible, 4240 ). % Frame number: 107 holdsAt( orientation( grp_ID0 )=57, 4280 ). holdsAt( appearance( grp_ID0 )=visible, 4280 ). % Frame number: 108 holdsAt( orientation( grp_ID0 )=57, 4320 ). holdsAt( appearance( grp_ID0 )=visible, 4320 ). % Frame number: 109 holdsAt( orientation( grp_ID0 )=57, 4360 ). holdsAt( appearance( grp_ID0 )=visible, 4360 ). % Frame number: 110 holdsAt( orientation( grp_ID0 )=57, 4400 ). holdsAt( appearance( grp_ID0 )=visible, 4400 ). % Frame number: 111 holdsAt( orientation( grp_ID0 )=57, 4440 ). holdsAt( appearance( grp_ID0 )=visible, 4440 ). % Frame number: 112 holdsAt( orientation( grp_ID0 )=57, 4480 ). holdsAt( appearance( grp_ID0 )=visible, 4480 ). % Frame number: 113 holdsAt( orientation( grp_ID0 )=57, 4520 ). holdsAt( appearance( grp_ID0 )=visible, 4520 ). % Frame number: 114 holdsAt( orientation( grp_ID0 )=57, 4560 ). holdsAt( appearance( grp_ID0 )=visible, 4560 ). % Frame number: 115 holdsAt( orientation( grp_ID0 )=57, 4600 ). holdsAt( appearance( grp_ID0 )=visible, 4600 ). % Frame number: 116 holdsAt( orientation( grp_ID0 )=57, 4640 ). holdsAt( appearance( grp_ID0 )=visible, 4640 ). % Frame number: 117 holdsAt( orientation( grp_ID0 )=57, 4680 ). holdsAt( appearance( grp_ID0 )=visible, 4680 ). % Frame number: 118 holdsAt( orientation( grp_ID0 )=57, 4720 ). holdsAt( appearance( grp_ID0 )=visible, 4720 ). % Frame number: 119 holdsAt( orientation( grp_ID0 )=57, 4760 ). holdsAt( appearance( grp_ID0 )=visible, 4760 ). % Frame number: 120 holdsAt( orientation( grp_ID0 )=57, 4800 ). holdsAt( appearance( grp_ID0 )=visible, 4800 ). % Frame number: 121 holdsAt( orientation( grp_ID0 )=57, 4840 ). holdsAt( appearance( grp_ID0 )=visible, 4840 ). % Frame number: 122 holdsAt( orientation( grp_ID0 )=57, 4880 ). holdsAt( appearance( grp_ID0 )=visible, 4880 ). % Frame number: 123 holdsAt( orientation( grp_ID0 )=57, 4920 ). holdsAt( appearance( grp_ID0 )=visible, 4920 ). % Frame number: 124 holdsAt( orientation( grp_ID0 )=57, 4960 ). holdsAt( appearance( grp_ID0 )=visible, 4960 ). % Frame number: 125 holdsAt( orientation( grp_ID0 )=57, 5000 ). holdsAt( appearance( grp_ID0 )=visible, 5000 ). % Frame number: 126 holdsAt( orientation( grp_ID0 )=57, 5040 ). holdsAt( appearance( grp_ID0 )=visible, 5040 ). % Frame number: 127 holdsAt( orientation( grp_ID0 )=57, 5080 ). holdsAt( appearance( grp_ID0 )=visible, 5080 ). % Frame number: 128 holdsAt( orientation( grp_ID0 )=57, 5120 ). holdsAt( appearance( grp_ID0 )=visible, 5120 ). % Frame number: 129 holdsAt( orientation( grp_ID0 )=57, 5160 ). holdsAt( appearance( grp_ID0 )=visible, 5160 ). % Frame number: 130 holdsAt( orientation( grp_ID0 )=57, 5200 ). holdsAt( appearance( grp_ID0 )=visible, 5200 ). % Frame number: 131 holdsAt( orientation( grp_ID0 )=57, 5240 ). holdsAt( appearance( grp_ID0 )=visible, 5240 ). % Frame number: 132 holdsAt( orientation( grp_ID0 )=57, 5280 ). holdsAt( appearance( grp_ID0 )=visible, 5280 ). % Frame number: 133 holdsAt( orientation( grp_ID0 )=57, 5320 ). holdsAt( appearance( grp_ID0 )=visible, 5320 ). % Frame number: 134 holdsAt( orientation( grp_ID0 )=57, 5360 ). holdsAt( appearance( grp_ID0 )=visible, 5360 ). % Frame number: 135 holdsAt( orientation( grp_ID0 )=57, 5400 ). holdsAt( appearance( grp_ID0 )=visible, 5400 ). % Frame number: 136 holdsAt( orientation( grp_ID0 )=57, 5440 ). holdsAt( appearance( grp_ID0 )=visible, 5440 ). % Frame number: 137 holdsAt( orientation( grp_ID0 )=57, 5480 ). holdsAt( appearance( grp_ID0 )=visible, 5480 ). % Frame number: 138 holdsAt( orientation( grp_ID0 )=57, 5520 ). holdsAt( appearance( grp_ID0 )=visible, 5520 ). % Frame number: 139 holdsAt( orientation( grp_ID0 )=57, 5560 ). holdsAt( appearance( grp_ID0 )=visible, 5560 ). % Frame number: 140 holdsAt( orientation( grp_ID0 )=57, 5600 ). holdsAt( appearance( grp_ID0 )=visible, 5600 ). % Frame number: 141 holdsAt( orientation( grp_ID0 )=57, 5640 ). holdsAt( appearance( grp_ID0 )=visible, 5640 ). % Frame number: 142 holdsAt( orientation( grp_ID0 )=57, 5680 ). holdsAt( appearance( grp_ID0 )=visible, 5680 ). % Frame number: 143 holdsAt( orientation( grp_ID0 )=57, 5720 ). holdsAt( appearance( grp_ID0 )=visible, 5720 ). % Frame number: 144 holdsAt( orientation( grp_ID0 )=57, 5760 ). holdsAt( appearance( grp_ID0 )=visible, 5760 ). % Frame number: 145 holdsAt( orientation( grp_ID0 )=57, 5800 ). holdsAt( appearance( grp_ID0 )=visible, 5800 ). % Frame number: 146 holdsAt( orientation( grp_ID0 )=57, 5840 ). holdsAt( appearance( grp_ID0 )=visible, 5840 ). % Frame number: 147 holdsAt( orientation( grp_ID0 )=57, 5880 ). holdsAt( appearance( grp_ID0 )=visible, 5880 ). % Frame number: 148 holdsAt( orientation( grp_ID0 )=57, 5920 ). holdsAt( appearance( grp_ID0 )=visible, 5920 ). % Frame number: 149 holdsAt( orientation( grp_ID0 )=57, 5960 ). holdsAt( appearance( grp_ID0 )=visible, 5960 ). % Frame number: 150 holdsAt( orientation( grp_ID0 )=57, 6000 ). holdsAt( appearance( grp_ID0 )=visible, 6000 ). % Frame number: 151 holdsAt( orientation( grp_ID0 )=57, 6040 ). holdsAt( appearance( grp_ID0 )=visible, 6040 ). % Frame number: 152 holdsAt( orientation( grp_ID0 )=57, 6080 ). holdsAt( appearance( grp_ID0 )=visible, 6080 ). % Frame number: 153 holdsAt( orientation( grp_ID0 )=57, 6120 ). holdsAt( appearance( grp_ID0 )=visible, 6120 ). % Frame number: 154 holdsAt( orientation( grp_ID0 )=57, 6160 ). holdsAt( appearance( grp_ID0 )=visible, 6160 ). % Frame number: 155 holdsAt( orientation( grp_ID0 )=57, 6200 ). holdsAt( appearance( grp_ID0 )=visible, 6200 ). % Frame number: 156 holdsAt( orientation( grp_ID0 )=57, 6240 ). holdsAt( appearance( grp_ID0 )=visible, 6240 ). % Frame number: 157 holdsAt( orientation( grp_ID0 )=57, 6280 ). holdsAt( appearance( grp_ID0 )=visible, 6280 ). % Frame number: 158 holdsAt( orientation( grp_ID0 )=57, 6320 ). holdsAt( appearance( grp_ID0 )=visible, 6320 ). % Frame number: 159 holdsAt( orientation( grp_ID0 )=67, 6360 ). holdsAt( appearance( grp_ID0 )=visible, 6360 ). % Frame number: 160 holdsAt( orientation( grp_ID0 )=67, 6400 ). holdsAt( appearance( grp_ID0 )=visible, 6400 ). % Frame number: 161 holdsAt( orientation( grp_ID0 )=67, 6440 ). holdsAt( appearance( grp_ID0 )=visible, 6440 ). % Frame number: 162 holdsAt( orientation( grp_ID0 )=67, 6480 ). holdsAt( appearance( grp_ID0 )=visible, 6480 ). % Frame number: 163 holdsAt( orientation( grp_ID0 )=67, 6520 ). holdsAt( appearance( grp_ID0 )=visible, 6520 ). % Frame number: 164 holdsAt( orientation( grp_ID0 )=67, 6560 ). holdsAt( appearance( grp_ID0 )=visible, 6560 ). % Frame number: 165 holdsAt( orientation( grp_ID0 )=67, 6600 ). holdsAt( appearance( grp_ID0 )=visible, 6600 ). % Frame number: 166 holdsAt( orientation( grp_ID0 )=67, 6640 ). holdsAt( appearance( grp_ID0 )=visible, 6640 ). % Frame number: 167 holdsAt( orientation( grp_ID0 )=67, 6680 ). holdsAt( appearance( grp_ID0 )=visible, 6680 ). % Frame number: 168 holdsAt( orientation( grp_ID0 )=69, 6720 ). holdsAt( appearance( grp_ID0 )=visible, 6720 ). % Frame number: 169 holdsAt( orientation( grp_ID0 )=69, 6760 ). holdsAt( appearance( grp_ID0 )=visible, 6760 ). % Frame number: 170 holdsAt( orientation( grp_ID0 )=69, 6800 ). holdsAt( appearance( grp_ID0 )=visible, 6800 ). % Frame number: 171 holdsAt( orientation( grp_ID0 )=69, 6840 ). holdsAt( appearance( grp_ID0 )=visible, 6840 ). % Frame number: 172 holdsAt( orientation( grp_ID0 )=69, 6880 ). holdsAt( appearance( grp_ID0 )=visible, 6880 ). % Frame number: 173 holdsAt( orientation( grp_ID0 )=69, 6920 ). holdsAt( appearance( grp_ID0 )=visible, 6920 ). % Frame number: 174 holdsAt( orientation( grp_ID0 )=69, 6960 ). holdsAt( appearance( grp_ID0 )=visible, 6960 ). % Frame number: 175 holdsAt( orientation( grp_ID0 )=69, 7000 ). holdsAt( appearance( grp_ID0 )=visible, 7000 ). % Frame number: 176 holdsAt( orientation( grp_ID0 )=69, 7040 ). holdsAt( appearance( grp_ID0 )=visible, 7040 ). % Frame number: 177 holdsAt( orientation( grp_ID0 )=69, 7080 ). holdsAt( appearance( grp_ID0 )=visible, 7080 ). % Frame number: 178 holdsAt( orientation( grp_ID0 )=69, 7120 ). holdsAt( appearance( grp_ID0 )=visible, 7120 ). % Frame number: 179 holdsAt( orientation( grp_ID0 )=69, 7160 ). holdsAt( appearance( grp_ID0 )=visible, 7160 ). % Frame number: 180 holdsAt( orientation( grp_ID0 )=69, 7200 ). holdsAt( appearance( grp_ID0 )=visible, 7200 ). % Frame number: 181 holdsAt( orientation( grp_ID0 )=69, 7240 ). holdsAt( appearance( grp_ID0 )=visible, 7240 ). % Frame number: 182 holdsAt( orientation( grp_ID0 )=69, 7280 ). holdsAt( appearance( grp_ID0 )=visible, 7280 ). % Frame number: 183 holdsAt( orientation( grp_ID0 )=69, 7320 ). holdsAt( appearance( grp_ID0 )=visible, 7320 ). % Frame number: 184 holdsAt( orientation( grp_ID0 )=69, 7360 ). holdsAt( appearance( grp_ID0 )=visible, 7360 ). % Frame number: 185 holdsAt( orientation( grp_ID0 )=69, 7400 ). holdsAt( appearance( grp_ID0 )=visible, 7400 ). % Frame number: 186 holdsAt( orientation( grp_ID0 )=69, 7440 ). holdsAt( appearance( grp_ID0 )=visible, 7440 ). % Frame number: 187 holdsAt( orientation( grp_ID0 )=69, 7480 ). holdsAt( appearance( grp_ID0 )=visible, 7480 ). % Frame number: 188 holdsAt( orientation( grp_ID0 )=69, 7520 ). holdsAt( appearance( grp_ID0 )=visible, 7520 ). % Frame number: 189 holdsAt( orientation( grp_ID0 )=69, 7560 ). holdsAt( appearance( grp_ID0 )=visible, 7560 ). % Frame number: 190 holdsAt( orientation( grp_ID0 )=69, 7600 ). holdsAt( appearance( grp_ID0 )=visible, 7600 ). % Frame number: 191 holdsAt( orientation( grp_ID0 )=69, 7640 ). holdsAt( appearance( grp_ID0 )=visible, 7640 ). % Frame number: 192 holdsAt( orientation( grp_ID0 )=69, 7680 ). holdsAt( appearance( grp_ID0 )=visible, 7680 ). % Frame number: 193 holdsAt( orientation( grp_ID0 )=69, 7720 ). holdsAt( appearance( grp_ID0 )=visible, 7720 ). % Frame number: 194 holdsAt( orientation( grp_ID0 )=69, 7760 ). holdsAt( appearance( grp_ID0 )=visible, 7760 ). % Frame number: 195 holdsAt( orientation( grp_ID0 )=69, 7800 ). holdsAt( appearance( grp_ID0 )=visible, 7800 ). % Frame number: 196 holdsAt( orientation( grp_ID0 )=69, 7840 ). holdsAt( appearance( grp_ID0 )=visible, 7840 ). % Frame number: 197 holdsAt( orientation( grp_ID0 )=69, 7880 ). holdsAt( appearance( grp_ID0 )=visible, 7880 ). % Frame number: 198 holdsAt( orientation( grp_ID0 )=69, 7920 ). holdsAt( appearance( grp_ID0 )=visible, 7920 ). % Frame number: 199 holdsAt( orientation( grp_ID0 )=69, 7960 ). holdsAt( appearance( grp_ID0 )=visible, 7960 ). % Frame number: 200 holdsAt( orientation( grp_ID0 )=69, 8000 ). holdsAt( appearance( grp_ID0 )=visible, 8000 ). % Frame number: 201 holdsAt( orientation( grp_ID0 )=69, 8040 ). holdsAt( appearance( grp_ID0 )=visible, 8040 ). % Frame number: 202 holdsAt( orientation( grp_ID0 )=69, 8080 ). holdsAt( appearance( grp_ID0 )=visible, 8080 ). % Frame number: 203 holdsAt( orientation( grp_ID0 )=69, 8120 ). holdsAt( appearance( grp_ID0 )=visible, 8120 ). % Frame number: 204 holdsAt( orientation( grp_ID0 )=69, 8160 ). holdsAt( appearance( grp_ID0 )=visible, 8160 ). % Frame number: 205 holdsAt( orientation( grp_ID0 )=69, 8200 ). holdsAt( appearance( grp_ID0 )=visible, 8200 ). % Frame number: 206 holdsAt( orientation( grp_ID0 )=69, 8240 ). holdsAt( appearance( grp_ID0 )=visible, 8240 ). % Frame number: 207 holdsAt( orientation( grp_ID0 )=69, 8280 ). holdsAt( appearance( grp_ID0 )=visible, 8280 ). % Frame number: 208 holdsAt( orientation( grp_ID0 )=69, 8320 ). holdsAt( appearance( grp_ID0 )=visible, 8320 ). % Frame number: 209 holdsAt( orientation( grp_ID0 )=69, 8360 ). holdsAt( appearance( grp_ID0 )=visible, 8360 ). % Frame number: 210 holdsAt( orientation( grp_ID0 )=69, 8400 ). holdsAt( appearance( grp_ID0 )=visible, 8400 ). % Frame number: 211 holdsAt( orientation( grp_ID0 )=69, 8440 ). holdsAt( appearance( grp_ID0 )=visible, 8440 ). % Frame number: 212 holdsAt( orientation( grp_ID0 )=69, 8480 ). holdsAt( appearance( grp_ID0 )=visible, 8480 ). % Frame number: 213 holdsAt( orientation( grp_ID0 )=69, 8520 ). holdsAt( appearance( grp_ID0 )=visible, 8520 ). % Frame number: 214 holdsAt( orientation( grp_ID0 )=69, 8560 ). holdsAt( appearance( grp_ID0 )=visible, 8560 ). % Frame number: 215 holdsAt( orientation( grp_ID0 )=69, 8600 ). holdsAt( appearance( grp_ID0 )=visible, 8600 ). % Frame number: 216 holdsAt( orientation( grp_ID0 )=69, 8640 ). holdsAt( appearance( grp_ID0 )=visible, 8640 ). % Frame number: 217 holdsAt( orientation( grp_ID0 )=69, 8680 ). holdsAt( appearance( grp_ID0 )=visible, 8680 ). % Frame number: 218 holdsAt( orientation( grp_ID0 )=69, 8720 ). holdsAt( appearance( grp_ID0 )=visible, 8720 ). % Frame number: 219 holdsAt( orientation( grp_ID0 )=69, 8760 ). holdsAt( appearance( grp_ID0 )=visible, 8760 ). % Frame number: 220 holdsAt( orientation( grp_ID0 )=69, 8800 ). holdsAt( appearance( grp_ID0 )=visible, 8800 ). % Frame number: 221 holdsAt( orientation( grp_ID0 )=69, 8840 ). holdsAt( appearance( grp_ID0 )=visible, 8840 ). % Frame number: 222 holdsAt( orientation( grp_ID0 )=69, 8880 ). holdsAt( appearance( grp_ID0 )=visible, 8880 ). % Frame number: 223 holdsAt( orientation( grp_ID0 )=69, 8920 ). holdsAt( appearance( grp_ID0 )=visible, 8920 ). % Frame number: 224 holdsAt( orientation( grp_ID0 )=69, 8960 ). holdsAt( appearance( grp_ID0 )=visible, 8960 ). % Frame number: 225 holdsAt( orientation( grp_ID0 )=69, 9000 ). holdsAt( appearance( grp_ID0 )=visible, 9000 ). % Frame number: 226 holdsAt( orientation( grp_ID0 )=69, 9040 ). holdsAt( appearance( grp_ID0 )=visible, 9040 ). % Frame number: 227 holdsAt( orientation( grp_ID0 )=69, 9080 ). holdsAt( appearance( grp_ID0 )=visible, 9080 ). % Frame number: 228 holdsAt( orientation( grp_ID0 )=69, 9120 ). holdsAt( appearance( grp_ID0 )=visible, 9120 ). % Frame number: 229 holdsAt( orientation( grp_ID0 )=69, 9160 ). holdsAt( appearance( grp_ID0 )=visible, 9160 ). % Frame number: 230 holdsAt( orientation( grp_ID0 )=69, 9200 ). holdsAt( appearance( grp_ID0 )=visible, 9200 ). % Frame number: 231 holdsAt( orientation( grp_ID0 )=69, 9240 ). holdsAt( appearance( grp_ID0 )=visible, 9240 ). % Frame number: 232 holdsAt( orientation( grp_ID0 )=69, 9280 ). holdsAt( appearance( grp_ID0 )=visible, 9280 ). % Frame number: 233 holdsAt( orientation( grp_ID0 )=69, 9320 ). holdsAt( appearance( grp_ID0 )=visible, 9320 ). % Frame number: 234 holdsAt( orientation( grp_ID0 )=69, 9360 ). holdsAt( appearance( grp_ID0 )=visible, 9360 ). % Frame number: 235 holdsAt( orientation( grp_ID0 )=69, 9400 ). holdsAt( appearance( grp_ID0 )=visible, 9400 ). % Frame number: 236 holdsAt( orientation( grp_ID0 )=69, 9440 ). holdsAt( appearance( grp_ID0 )=visible, 9440 ). % Frame number: 237 holdsAt( orientation( grp_ID0 )=69, 9480 ). holdsAt( appearance( grp_ID0 )=visible, 9480 ). % Frame number: 238 holdsAt( orientation( grp_ID0 )=69, 9520 ). holdsAt( appearance( grp_ID0 )=visible, 9520 ). % Frame number: 239 holdsAt( orientation( grp_ID0 )=69, 9560 ). holdsAt( appearance( grp_ID0 )=visible, 9560 ). % Frame number: 240 holdsAt( orientation( grp_ID0 )=69, 9600 ). holdsAt( appearance( grp_ID0 )=visible, 9600 ). % Frame number: 241 holdsAt( orientation( grp_ID0 )=69, 9640 ). holdsAt( appearance( grp_ID0 )=visible, 9640 ). % Frame number: 242 holdsAt( orientation( grp_ID0 )=69, 9680 ). holdsAt( appearance( grp_ID0 )=visible, 9680 ). % Frame number: 243 holdsAt( orientation( grp_ID0 )=69, 9720 ). holdsAt( appearance( grp_ID0 )=visible, 9720 ). % Frame number: 244 holdsAt( orientation( grp_ID0 )=69, 9760 ). holdsAt( appearance( grp_ID0 )=visible, 9760 ). % Frame number: 245 holdsAt( orientation( grp_ID0 )=69, 9800 ). holdsAt( appearance( grp_ID0 )=visible, 9800 ). % Frame number: 246 holdsAt( orientation( grp_ID0 )=69, 9840 ). holdsAt( appearance( grp_ID0 )=visible, 9840 ). % Frame number: 247 holdsAt( orientation( grp_ID0 )=69, 9880 ). holdsAt( appearance( grp_ID0 )=visible, 9880 ). % Frame number: 248 holdsAt( orientation( grp_ID0 )=69, 9920 ). holdsAt( appearance( grp_ID0 )=visible, 9920 ). % Frame number: 249 holdsAt( orientation( grp_ID0 )=69, 9960 ). holdsAt( appearance( grp_ID0 )=visible, 9960 ). % Frame number: 250 holdsAt( orientation( grp_ID0 )=69, 10000 ). holdsAt( appearance( grp_ID0 )=visible, 10000 ). % Frame number: 251 holdsAt( orientation( grp_ID0 )=69, 10040 ). holdsAt( appearance( grp_ID0 )=visible, 10040 ). % Frame number: 252 holdsAt( orientation( grp_ID0 )=69, 10080 ). holdsAt( appearance( grp_ID0 )=visible, 10080 ). % Frame number: 253 holdsAt( orientation( grp_ID0 )=69, 10120 ). holdsAt( appearance( grp_ID0 )=visible, 10120 ). % Frame number: 254 holdsAt( orientation( grp_ID0 )=69, 10160 ). holdsAt( appearance( grp_ID0 )=visible, 10160 ). % Frame number: 255 holdsAt( orientation( grp_ID0 )=69, 10200 ). holdsAt( appearance( grp_ID0 )=visible, 10200 ). % Frame number: 256 holdsAt( orientation( grp_ID0 )=67, 10240 ). holdsAt( appearance( grp_ID0 )=visible, 10240 ). % Frame number: 257 holdsAt( orientation( grp_ID0 )=66, 10280 ). holdsAt( appearance( grp_ID0 )=visible, 10280 ). % Frame number: 258 holdsAt( orientation( grp_ID0 )=65, 10320 ). holdsAt( appearance( grp_ID0 )=visible, 10320 ). % Frame number: 259 holdsAt( orientation( grp_ID0 )=63, 10360 ). holdsAt( appearance( grp_ID0 )=visible, 10360 ). % Frame number: 260 holdsAt( orientation( grp_ID0 )=62, 10400 ). holdsAt( appearance( grp_ID0 )=visible, 10400 ). % Frame number: 261 holdsAt( orientation( grp_ID0 )=61, 10440 ). holdsAt( appearance( grp_ID0 )=visible, 10440 ). % Frame number: 262 holdsAt( orientation( grp_ID0 )=61, 10480 ). holdsAt( appearance( grp_ID0 )=visible, 10480 ). % Frame number: 263 holdsAt( orientation( grp_ID0 )=56, 10520 ). holdsAt( appearance( grp_ID0 )=visible, 10520 ). % Frame number: 264 holdsAt( orientation( grp_ID0 )=51, 10560 ). holdsAt( appearance( grp_ID0 )=visible, 10560 ). % Frame number: 265 holdsAt( orientation( grp_ID0 )=51, 10600 ). holdsAt( appearance( grp_ID0 )=visible, 10600 ). % Frame number: 266 holdsAt( orientation( grp_ID0 )=51, 10640 ). holdsAt( appearance( grp_ID0 )=visible, 10640 ). % Frame number: 267 holdsAt( orientation( grp_ID0 )=51, 10680 ). holdsAt( appearance( grp_ID0 )=visible, 10680 ). % Frame number: 268 holdsAt( orientation( grp_ID0 )=51, 10720 ). holdsAt( appearance( grp_ID0 )=visible, 10720 ). % Frame number: 269 holdsAt( orientation( grp_ID0 )=51, 10760 ). holdsAt( appearance( grp_ID0 )=visible, 10760 ). % Frame number: 270 holdsAt( orientation( grp_ID0 )=51, 10800 ). holdsAt( appearance( grp_ID0 )=visible, 10800 ). % Frame number: 271 holdsAt( orientation( grp_ID0 )=51, 10840 ). holdsAt( appearance( grp_ID0 )=visible, 10840 ). % Frame number: 272 holdsAt( orientation( grp_ID0 )=51, 10880 ). holdsAt( appearance( grp_ID0 )=visible, 10880 ). % Frame number: 273 holdsAt( orientation( grp_ID0 )=51, 10920 ). holdsAt( appearance( grp_ID0 )=visible, 10920 ). % Frame number: 274 holdsAt( orientation( grp_ID0 )=51, 10960 ). holdsAt( appearance( grp_ID0 )=visible, 10960 ). % Frame number: 275 holdsAt( orientation( grp_ID0 )=47, 11000 ). holdsAt( appearance( grp_ID0 )=visible, 11000 ). % Frame number: 276 holdsAt( orientation( grp_ID0 )=43, 11040 ). holdsAt( appearance( grp_ID0 )=visible, 11040 ). % Frame number: 277 holdsAt( orientation( grp_ID0 )=41, 11080 ). holdsAt( appearance( grp_ID0 )=visible, 11080 ). % Frame number: 278 holdsAt( orientation( grp_ID0 )=36, 11120 ). holdsAt( appearance( grp_ID0 )=visible, 11120 ). % Frame number: 279 holdsAt( orientation( grp_ID0 )=31, 11160 ). holdsAt( appearance( grp_ID0 )=visible, 11160 ). % Frame number: 280 holdsAt( orientation( grp_ID0 )=26, 11200 ). holdsAt( appearance( grp_ID0 )=visible, 11200 ). % Frame number: 281 holdsAt( orientation( grp_ID0 )=24, 11240 ). holdsAt( appearance( grp_ID0 )=visible, 11240 ). % Frame number: 282 holdsAt( orientation( grp_ID0 )=19, 11280 ). holdsAt( appearance( grp_ID0 )=visible, 11280 ). % Frame number: 283 holdsAt( orientation( grp_ID0 )=19, 11320 ). holdsAt( appearance( grp_ID0 )=visible, 11320 ). % Frame number: 284 holdsAt( orientation( grp_ID0 )=18, 11360 ). holdsAt( appearance( grp_ID0 )=visible, 11360 ). % Frame number: 285 holdsAt( orientation( grp_ID0 )=14, 11400 ). holdsAt( appearance( grp_ID0 )=visible, 11400 ). % Frame number: 286 holdsAt( orientation( grp_ID0 )=13, 11440 ). holdsAt( appearance( grp_ID0 )=visible, 11440 ). % Frame number: 287 holdsAt( orientation( grp_ID0 )=13, 11480 ). holdsAt( appearance( grp_ID0 )=visible, 11480 ). % Frame number: 288 holdsAt( orientation( grp_ID0 )=9, 11520 ). holdsAt( appearance( grp_ID0 )=visible, 11520 ). % Frame number: 289 holdsAt( orientation( grp_ID0 )=9, 11560 ). holdsAt( appearance( grp_ID0 )=visible, 11560 ). % Frame number: 290 holdsAt( orientation( grp_ID0 )=12, 11600 ). holdsAt( appearance( grp_ID0 )=visible, 11600 ). % Frame number: 291 holdsAt( orientation( grp_ID0 )=6, 11640 ). holdsAt( appearance( grp_ID0 )=visible, 11640 ). % Frame number: 292 holdsAt( orientation( grp_ID0 )=5, 11680 ). holdsAt( appearance( grp_ID0 )=visible, 11680 ). % Frame number: 293 holdsAt( orientation( grp_ID0 )=5, 11720 ). holdsAt( appearance( grp_ID0 )=visible, 11720 ). % Frame number: 294 holdsAt( orientation( grp_ID0 )=5, 11760 ). holdsAt( appearance( grp_ID0 )=visible, 11760 ). % Frame number: 295 holdsAt( orientation( grp_ID0 )=5, 11800 ). holdsAt( appearance( grp_ID0 )=visible, 11800 ). % Frame number: 296 holdsAt( orientation( grp_ID0 )=5, 11840 ). holdsAt( appearance( grp_ID0 )=visible, 11840 ). % Frame number: 297 holdsAt( orientation( grp_ID0 )=5, 11880 ). holdsAt( appearance( grp_ID0 )=visible, 11880 ). % Frame number: 298 holdsAt( orientation( grp_ID0 )=5, 11920 ). holdsAt( appearance( grp_ID0 )=visible, 11920 ). % Frame number: 299 holdsAt( orientation( grp_ID0 )=5, 11960 ). holdsAt( appearance( grp_ID0 )=visible, 11960 ). % Frame number: 300 holdsAt( orientation( grp_ID0 )=5, 12000 ). holdsAt( appearance( grp_ID0 )=visible, 12000 ). % Frame number: 301 holdsAt( orientation( grp_ID0 )=5, 12040 ). holdsAt( appearance( grp_ID0 )=visible, 12040 ). % Frame number: 302 holdsAt( orientation( grp_ID0 )=5, 12080 ). holdsAt( appearance( grp_ID0 )=visible, 12080 ). % Frame number: 303 holdsAt( orientation( grp_ID0 )=10, 12120 ). holdsAt( appearance( grp_ID0 )=visible, 12120 ). % Frame number: 304 holdsAt( orientation( grp_ID0 )=9, 12160 ). holdsAt( appearance( grp_ID0 )=visible, 12160 ). % Frame number: 305 holdsAt( orientation( grp_ID0 )=17, 12200 ). holdsAt( appearance( grp_ID0 )=visible, 12200 ). % Frame number: 306 holdsAt( orientation( grp_ID0 )=21, 12240 ). holdsAt( appearance( grp_ID0 )=visible, 12240 ). % Frame number: 307 holdsAt( orientation( grp_ID0 )=16, 12280 ). holdsAt( appearance( grp_ID0 )=visible, 12280 ). % Frame number: 308 holdsAt( orientation( grp_ID0 )=23, 12320 ). holdsAt( appearance( grp_ID0 )=visible, 12320 ). % Frame number: 309 holdsAt( orientation( grp_ID0 )=23, 12360 ). holdsAt( appearance( grp_ID0 )=visible, 12360 ). % Frame number: 310 holdsAt( orientation( grp_ID0 )=25, 12400 ). holdsAt( appearance( grp_ID0 )=visible, 12400 ). % Frame number: 311 holdsAt( orientation( grp_ID0 )=30, 12440 ). holdsAt( appearance( grp_ID0 )=visible, 12440 ). % Frame number: 312 holdsAt( orientation( grp_ID0 )=32, 12480 ). holdsAt( appearance( grp_ID0 )=visible, 12480 ). % Frame number: 313 holdsAt( orientation( grp_ID0 )=32, 12520 ). holdsAt( appearance( grp_ID0 )=visible, 12520 ). % Frame number: 314 holdsAt( orientation( grp_ID0 )=32, 12560 ). holdsAt( appearance( grp_ID0 )=visible, 12560 ). % Frame number: 315 holdsAt( orientation( grp_ID0 )=40, 12600 ). holdsAt( appearance( grp_ID0 )=visible, 12600 ). % Frame number: 316 holdsAt( orientation( grp_ID0 )=40, 12640 ). holdsAt( appearance( grp_ID0 )=visible, 12640 ). % Frame number: 317 holdsAt( orientation( grp_ID0 )=40, 12680 ). holdsAt( appearance( grp_ID0 )=visible, 12680 ). % Frame number: 318 holdsAt( orientation( grp_ID0 )=41, 12720 ). holdsAt( appearance( grp_ID0 )=visible, 12720 ). % Frame number: 319 holdsAt( orientation( grp_ID0 )=42, 12760 ). holdsAt( appearance( grp_ID0 )=visible, 12760 ). % Frame number: 320 holdsAt( orientation( grp_ID0 )=46, 12800 ). holdsAt( appearance( grp_ID0 )=visible, 12800 ). % Frame number: 321 holdsAt( orientation( grp_ID0 )=44, 12840 ). holdsAt( appearance( grp_ID0 )=visible, 12840 ). % Frame number: 322 holdsAt( orientation( grp_ID0 )=46, 12880 ). holdsAt( appearance( grp_ID0 )=visible, 12880 ). % Frame number: 323 holdsAt( orientation( grp_ID0 )=48, 12920 ). holdsAt( appearance( grp_ID0 )=visible, 12920 ). % Frame number: 324 holdsAt( orientation( grp_ID0 )=45, 12960 ). holdsAt( appearance( grp_ID0 )=visible, 12960 ). % Frame number: 325 holdsAt( orientation( grp_ID0 )=46, 13000 ). holdsAt( appearance( grp_ID0 )=visible, 13000 ). % Frame number: 326 holdsAt( orientation( grp_ID0 )=45, 13040 ). holdsAt( appearance( grp_ID0 )=visible, 13040 ). % Frame number: 327 holdsAt( orientation( grp_ID0 )=42, 13080 ). holdsAt( appearance( grp_ID0 )=visible, 13080 ). % Frame number: 328 holdsAt( orientation( grp_ID0 )=44, 13120 ). holdsAt( appearance( grp_ID0 )=visible, 13120 ). % Frame number: 329 holdsAt( orientation( grp_ID0 )=42, 13160 ). holdsAt( appearance( grp_ID0 )=visible, 13160 ). % Frame number: 330 holdsAt( orientation( grp_ID0 )=41, 13200 ). holdsAt( appearance( grp_ID0 )=visible, 13200 ). % Frame number: 331 holdsAt( orientation( grp_ID0 )=45, 13240 ). holdsAt( appearance( grp_ID0 )=visible, 13240 ). % Frame number: 332 holdsAt( orientation( grp_ID0 )=41, 13280 ). holdsAt( appearance( grp_ID0 )=visible, 13280 ). % Frame number: 333 holdsAt( orientation( grp_ID0 )=39, 13320 ). holdsAt( appearance( grp_ID0 )=visible, 13320 ). % Frame number: 334 holdsAt( orientation( grp_ID0 )=40, 13360 ). holdsAt( appearance( grp_ID0 )=visible, 13360 ). % Frame number: 335 holdsAt( orientation( grp_ID0 )=43, 13400 ). holdsAt( appearance( grp_ID0 )=visible, 13400 ). % Frame number: 336 holdsAt( orientation( grp_ID0 )=43, 13440 ). holdsAt( appearance( grp_ID0 )=visible, 13440 ). % Frame number: 337 holdsAt( orientation( grp_ID0 )=43, 13480 ). holdsAt( appearance( grp_ID0 )=visible, 13480 ). % Frame number: 338 holdsAt( orientation( grp_ID0 )=43, 13520 ). holdsAt( appearance( grp_ID0 )=visible, 13520 ). % Frame number: 339 holdsAt( orientation( grp_ID0 )=43, 13560 ). holdsAt( appearance( grp_ID0 )=visible, 13560 ). % Frame number: 340 holdsAt( orientation( grp_ID0 )=43, 13600 ). holdsAt( appearance( grp_ID0 )=visible, 13600 ). % Frame number: 341 holdsAt( orientation( grp_ID0 )=43, 13640 ). holdsAt( appearance( grp_ID0 )=visible, 13640 ). % Frame number: 342 holdsAt( orientation( grp_ID0 )=43, 13680 ). holdsAt( appearance( grp_ID0 )=visible, 13680 ). % Frame number: 343 holdsAt( orientation( grp_ID0 )=43, 13720 ). holdsAt( appearance( grp_ID0 )=visible, 13720 ). % Frame number: 344 holdsAt( orientation( grp_ID0 )=43, 13760 ). holdsAt( appearance( grp_ID0 )=visible, 13760 ). % Frame number: 345 holdsAt( orientation( grp_ID0 )=43, 13800 ). holdsAt( appearance( grp_ID0 )=visible, 13800 ). % Frame number: 346 holdsAt( orientation( grp_ID0 )=43, 13840 ). holdsAt( appearance( grp_ID0 )=visible, 13840 ). % Frame number: 347 holdsAt( orientation( grp_ID0 )=43, 13880 ). holdsAt( appearance( grp_ID0 )=visible, 13880 ). % Frame number: 348 holdsAt( orientation( grp_ID0 )=43, 13920 ). holdsAt( appearance( grp_ID0 )=visible, 13920 ). % Frame number: 349 holdsAt( orientation( grp_ID0 )=43, 13960 ). holdsAt( appearance( grp_ID0 )=visible, 13960 ). % Frame number: 350 holdsAt( orientation( grp_ID0 )=43, 14000 ). holdsAt( appearance( grp_ID0 )=visible, 14000 ). % Frame number: 351 holdsAt( orientation( grp_ID0 )=43, 14040 ). holdsAt( appearance( grp_ID0 )=visible, 14040 ). % Frame number: 352 holdsAt( orientation( grp_ID0 )=43, 14080 ). holdsAt( appearance( grp_ID0 )=visible, 14080 ). % Frame number: 353 holdsAt( orientation( grp_ID0 )=43, 14120 ). holdsAt( appearance( grp_ID0 )=visible, 14120 ). % Frame number: 354 holdsAt( orientation( grp_ID0 )=43, 14160 ). holdsAt( appearance( grp_ID0 )=visible, 14160 ). % Frame number: 355 holdsAt( orientation( grp_ID0 )=43, 14200 ). holdsAt( appearance( grp_ID0 )=visible, 14200 ). % Frame number: 356 holdsAt( orientation( grp_ID0 )=43, 14240 ). holdsAt( appearance( grp_ID0 )=visible, 14240 ). % Frame number: 357 holdsAt( orientation( grp_ID0 )=52, 14280 ). holdsAt( appearance( grp_ID0 )=visible, 14280 ). % Frame number: 358 holdsAt( orientation( grp_ID0 )=52, 14320 ). holdsAt( appearance( grp_ID0 )=visible, 14320 ). % Frame number: 359 holdsAt( orientation( grp_ID0 )=52, 14360 ). holdsAt( appearance( grp_ID0 )=visible, 14360 ). % Frame number: 360 holdsAt( orientation( grp_ID0 )=52, 14400 ). holdsAt( appearance( grp_ID0 )=visible, 14400 ). % Frame number: 361 holdsAt( orientation( grp_ID0 )=52, 14440 ). holdsAt( appearance( grp_ID0 )=visible, 14440 ). % Frame number: 362 holdsAt( orientation( grp_ID0 )=52, 14480 ). holdsAt( appearance( grp_ID0 )=visible, 14480 ). % Frame number: 363 holdsAt( orientation( grp_ID0 )=52, 14520 ). holdsAt( appearance( grp_ID0 )=visible, 14520 ). % Frame number: 364 holdsAt( orientation( grp_ID0 )=52, 14560 ). holdsAt( appearance( grp_ID0 )=visible, 14560 ). % Frame number: 365 holdsAt( orientation( grp_ID0 )=52, 14600 ). holdsAt( appearance( grp_ID0 )=visible, 14600 ). % Frame number: 366 holdsAt( orientation( grp_ID0 )=52, 14640 ). holdsAt( appearance( grp_ID0 )=visible, 14640 ). % Frame number: 367 holdsAt( orientation( grp_ID0 )=52, 14680 ). holdsAt( appearance( grp_ID0 )=visible, 14680 ). % Frame number: 368 holdsAt( orientation( grp_ID0 )=52, 14720 ). holdsAt( appearance( grp_ID0 )=visible, 14720 ). % Frame number: 369 holdsAt( orientation( grp_ID0 )=52, 14760 ). holdsAt( appearance( grp_ID0 )=visible, 14760 ). % Frame number: 370 holdsAt( orientation( grp_ID0 )=52, 14800 ). holdsAt( appearance( grp_ID0 )=visible, 14800 ). % Frame number: 371 holdsAt( orientation( grp_ID0 )=52, 14840 ). holdsAt( appearance( grp_ID0 )=visible, 14840 ). % Frame number: 372 holdsAt( orientation( grp_ID0 )=52, 14880 ). holdsAt( appearance( grp_ID0 )=visible, 14880 ). % Frame number: 373 holdsAt( orientation( grp_ID0 )=52, 14920 ). holdsAt( appearance( grp_ID0 )=visible, 14920 ). % Frame number: 374 holdsAt( orientation( grp_ID0 )=52, 14960 ). holdsAt( appearance( grp_ID0 )=visible, 14960 ). % Frame number: 375 holdsAt( orientation( grp_ID0 )=52, 15000 ). holdsAt( appearance( grp_ID0 )=visible, 15000 ). % Frame number: 376 holdsAt( orientation( grp_ID0 )=52, 15040 ). holdsAt( appearance( grp_ID0 )=visible, 15040 ). % Frame number: 377 holdsAt( orientation( grp_ID0 )=52, 15080 ). holdsAt( appearance( grp_ID0 )=visible, 15080 ). % Frame number: 378 holdsAt( orientation( grp_ID0 )=52, 15120 ). holdsAt( appearance( grp_ID0 )=visible, 15120 ). % Frame number: 379 holdsAt( orientation( grp_ID0 )=52, 15160 ). holdsAt( appearance( grp_ID0 )=visible, 15160 ). % Frame number: 380 holdsAt( orientation( grp_ID0 )=52, 15200 ). holdsAt( appearance( grp_ID0 )=visible, 15200 ). % Frame number: 381 holdsAt( orientation( grp_ID0 )=52, 15240 ). holdsAt( appearance( grp_ID0 )=visible, 15240 ). % Frame number: 382 holdsAt( orientation( grp_ID0 )=52, 15280 ). holdsAt( appearance( grp_ID0 )=visible, 15280 ). % Frame number: 383 holdsAt( orientation( grp_ID0 )=52, 15320 ). holdsAt( appearance( grp_ID0 )=visible, 15320 ). % Frame number: 384 holdsAt( orientation( grp_ID0 )=52, 15360 ). holdsAt( appearance( grp_ID0 )=visible, 15360 ). % Frame number: 385 holdsAt( orientation( grp_ID0 )=52, 15400 ). holdsAt( appearance( grp_ID0 )=visible, 15400 ). % Frame number: 386 holdsAt( orientation( grp_ID0 )=52, 15440 ). holdsAt( appearance( grp_ID0 )=visible, 15440 ). % Frame number: 387 holdsAt( orientation( grp_ID0 )=52, 15480 ). holdsAt( appearance( grp_ID0 )=visible, 15480 ). % Frame number: 388 holdsAt( orientation( grp_ID0 )=52, 15520 ). holdsAt( appearance( grp_ID0 )=visible, 15520 ). % Frame number: 389 holdsAt( orientation( grp_ID0 )=52, 15560 ). holdsAt( appearance( grp_ID0 )=visible, 15560 ). % Frame number: 390 holdsAt( orientation( grp_ID0 )=52, 15600 ). holdsAt( appearance( grp_ID0 )=visible, 15600 ). % Frame number: 391 holdsAt( orientation( grp_ID0 )=52, 15640 ). holdsAt( appearance( grp_ID0 )=visible, 15640 ). % Frame number: 392 holdsAt( orientation( grp_ID0 )=52, 15680 ). holdsAt( appearance( grp_ID0 )=visible, 15680 ). % Frame number: 393 holdsAt( orientation( grp_ID0 )=52, 15720 ). holdsAt( appearance( grp_ID0 )=visible, 15720 ). % Frame number: 394 holdsAt( orientation( grp_ID0 )=52, 15760 ). holdsAt( appearance( grp_ID0 )=visible, 15760 ). % Frame number: 395 holdsAt( orientation( grp_ID0 )=52, 15800 ). holdsAt( appearance( grp_ID0 )=visible, 15800 ). % Frame number: 396 holdsAt( orientation( grp_ID0 )=52, 15840 ). holdsAt( appearance( grp_ID0 )=visible, 15840 ). % Frame number: 397 holdsAt( orientation( grp_ID0 )=52, 15880 ). holdsAt( appearance( grp_ID0 )=visible, 15880 ). % Frame number: 398 holdsAt( orientation( grp_ID0 )=52, 15920 ). holdsAt( appearance( grp_ID0 )=visible, 15920 ). % Frame number: 399 holdsAt( orientation( grp_ID0 )=52, 15960 ). holdsAt( appearance( grp_ID0 )=visible, 15960 ). % Frame number: 400 holdsAt( orientation( grp_ID0 )=52, 16000 ). holdsAt( appearance( grp_ID0 )=visible, 16000 ). % Frame number: 401 holdsAt( orientation( grp_ID0 )=52, 16040 ). holdsAt( appearance( grp_ID0 )=visible, 16040 ). % Frame number: 402 holdsAt( orientation( grp_ID0 )=52, 16080 ). holdsAt( appearance( grp_ID0 )=visible, 16080 ). % Frame number: 403 holdsAt( orientation( grp_ID0 )=52, 16120 ). holdsAt( appearance( grp_ID0 )=visible, 16120 ). % Frame number: 404 holdsAt( orientation( grp_ID0 )=52, 16160 ). holdsAt( appearance( grp_ID0 )=visible, 16160 ). % Frame number: 405 holdsAt( orientation( grp_ID0 )=52, 16200 ). holdsAt( appearance( grp_ID0 )=visible, 16200 ). % Frame number: 406 holdsAt( orientation( grp_ID0 )=52, 16240 ). holdsAt( appearance( grp_ID0 )=visible, 16240 ). % Frame number: 407 holdsAt( orientation( grp_ID0 )=52, 16280 ). holdsAt( appearance( grp_ID0 )=visible, 16280 ). % Frame number: 408 holdsAt( orientation( grp_ID0 )=52, 16320 ). holdsAt( appearance( grp_ID0 )=visible, 16320 ). % Frame number: 409 holdsAt( orientation( grp_ID0 )=52, 16360 ). holdsAt( appearance( grp_ID0 )=visible, 16360 ). % Frame number: 410 holdsAt( orientation( grp_ID0 )=52, 16400 ). holdsAt( appearance( grp_ID0 )=visible, 16400 ). % Frame number: 411 holdsAt( orientation( grp_ID0 )=52, 16440 ). holdsAt( appearance( grp_ID0 )=visible, 16440 ). % Frame number: 412 holdsAt( orientation( grp_ID0 )=52, 16480 ). holdsAt( appearance( grp_ID0 )=visible, 16480 ). % Frame number: 413 holdsAt( orientation( grp_ID0 )=52, 16520 ). holdsAt( appearance( grp_ID0 )=visible, 16520 ). % Frame number: 414 holdsAt( orientation( grp_ID0 )=52, 16560 ). holdsAt( appearance( grp_ID0 )=visible, 16560 ). % Frame number: 415 holdsAt( orientation( grp_ID0 )=52, 16600 ). holdsAt( appearance( grp_ID0 )=visible, 16600 ). % Frame number: 416 holdsAt( orientation( grp_ID0 )=52, 16640 ). holdsAt( appearance( grp_ID0 )=visible, 16640 ). % Frame number: 417 holdsAt( orientation( grp_ID0 )=52, 16680 ). holdsAt( appearance( grp_ID0 )=visible, 16680 ). % Frame number: 418 holdsAt( orientation( grp_ID0 )=52, 16720 ). holdsAt( appearance( grp_ID0 )=visible, 16720 ). % Frame number: 419 holdsAt( orientation( grp_ID0 )=55, 16760 ). holdsAt( appearance( grp_ID0 )=visible, 16760 ). % Frame number: 420 holdsAt( orientation( grp_ID0 )=60, 16800 ). holdsAt( appearance( grp_ID0 )=visible, 16800 ). % Frame number: 421 holdsAt( orientation( grp_ID0 )=61, 16840 ). holdsAt( appearance( grp_ID0 )=visible, 16840 ). % Frame number: 422 holdsAt( orientation( grp_ID0 )=61, 16880 ). holdsAt( appearance( grp_ID0 )=visible, 16880 ). % Frame number: 423 holdsAt( orientation( grp_ID0 )=59, 16920 ). holdsAt( appearance( grp_ID0 )=visible, 16920 ). % Frame number: 424 holdsAt( orientation( grp_ID0 )=62, 16960 ). holdsAt( appearance( grp_ID0 )=visible, 16960 ). % Frame number: 425 holdsAt( orientation( grp_ID0 )=60, 17000 ). holdsAt( appearance( grp_ID0 )=visible, 17000 ). % Frame number: 426 holdsAt( orientation( grp_ID0 )=62, 17040 ). holdsAt( appearance( grp_ID0 )=visible, 17040 ). % Frame number: 427 holdsAt( orientation( grp_ID0 )=60, 17080 ). holdsAt( appearance( grp_ID0 )=visible, 17080 ). % Frame number: 428 holdsAt( orientation( grp_ID0 )=58, 17120 ). holdsAt( appearance( grp_ID0 )=visible, 17120 ). % Frame number: 429 holdsAt( orientation( grp_ID0 )=62, 17160 ). holdsAt( appearance( grp_ID0 )=visible, 17160 ). % Frame number: 430 holdsAt( orientation( grp_ID0 )=62, 17200 ). holdsAt( appearance( grp_ID0 )=visible, 17200 ). % Frame number: 431 holdsAt( orientation( grp_ID0 )=60, 17240 ). holdsAt( appearance( grp_ID0 )=visible, 17240 ). % Frame number: 432 holdsAt( orientation( grp_ID0 )=63, 17280 ). holdsAt( appearance( grp_ID0 )=visible, 17280 ). % Frame number: 433 holdsAt( orientation( grp_ID0 )=62, 17320 ). holdsAt( appearance( grp_ID0 )=visible, 17320 ). % Frame number: 434 holdsAt( orientation( grp_ID0 )=63, 17360 ). holdsAt( appearance( grp_ID0 )=visible, 17360 ). % Frame number: 435 holdsAt( orientation( grp_ID0 )=66, 17400 ). holdsAt( appearance( grp_ID0 )=visible, 17400 ). % Frame number: 436 holdsAt( orientation( grp_ID0 )=69, 17440 ). holdsAt( appearance( grp_ID0 )=visible, 17440 ). % Frame number: 437 holdsAt( orientation( grp_ID0 )=67, 17480 ). holdsAt( appearance( grp_ID0 )=visible, 17480 ). % Frame number: 438 holdsAt( orientation( grp_ID0 )=67, 17520 ). holdsAt( appearance( grp_ID0 )=visible, 17520 ). % Frame number: 439 holdsAt( orientation( grp_ID0 )=67, 17560 ). holdsAt( appearance( grp_ID0 )=visible, 17560 ). % Frame number: 440 holdsAt( orientation( grp_ID0 )=67, 17600 ). holdsAt( appearance( grp_ID0 )=visible, 17600 ). % Frame number: 441 holdsAt( orientation( grp_ID0 )=67, 17640 ). holdsAt( appearance( grp_ID0 )=visible, 17640 ). % Frame number: 442 holdsAt( orientation( grp_ID0 )=71, 17680 ). holdsAt( appearance( grp_ID0 )=visible, 17680 ). % Frame number: 443 holdsAt( orientation( grp_ID0 )=78, 17720 ). holdsAt( appearance( grp_ID0 )=visible, 17720 ). % Frame number: 444 holdsAt( orientation( grp_ID0 )=78, 17760 ). holdsAt( appearance( grp_ID0 )=visible, 17760 ). % Frame number: 445 holdsAt( orientation( grp_ID0 )=78, 17800 ). holdsAt( appearance( grp_ID0 )=visible, 17800 ). % Frame number: 446 holdsAt( orientation( grp_ID0 )=78, 17840 ). holdsAt( appearance( grp_ID0 )=visible, 17840 ). % Frame number: 447 holdsAt( orientation( grp_ID0 )=78, 17880 ). holdsAt( appearance( grp_ID0 )=visible, 17880 ). % Frame number: 448 holdsAt( orientation( grp_ID0 )=78, 17920 ). holdsAt( appearance( grp_ID0 )=visible, 17920 ). % Frame number: 449 holdsAt( orientation( grp_ID0 )=78, 17960 ). holdsAt( appearance( grp_ID0 )=visible, 17960 ). % Frame number: 450 holdsAt( orientation( grp_ID0 )=84, 18000 ). holdsAt( appearance( grp_ID0 )=visible, 18000 ). % Frame number: 451 holdsAt( orientation( grp_ID0 )=84, 18040 ). holdsAt( appearance( grp_ID0 )=visible, 18040 ). % Frame number: 452 holdsAt( orientation( grp_ID0 )=84, 18080 ). holdsAt( appearance( grp_ID0 )=visible, 18080 ). % Frame number: 453 holdsAt( orientation( grp_ID0 )=84, 18120 ). holdsAt( appearance( grp_ID0 )=visible, 18120 ). % Frame number: 454 holdsAt( orientation( grp_ID0 )=84, 18160 ). holdsAt( appearance( grp_ID0 )=visible, 18160 ). % Frame number: 455 holdsAt( orientation( grp_ID0 )=87, 18200 ). holdsAt( appearance( grp_ID0 )=visible, 18200 ). % Frame number: 456 holdsAt( orientation( grp_ID0 )=87, 18240 ). holdsAt( appearance( grp_ID0 )=visible, 18240 ). % Frame number: 457 holdsAt( orientation( grp_ID0 )=87, 18280 ). holdsAt( appearance( grp_ID0 )=visible, 18280 ). % Frame number: 458 holdsAt( orientation( grp_ID0 )=87, 18320 ). holdsAt( appearance( grp_ID0 )=visible, 18320 ). % Frame number: 459 holdsAt( orientation( grp_ID0 )=87, 18360 ). holdsAt( appearance( grp_ID0 )=visible, 18360 ). % Frame number: 460 holdsAt( orientation( grp_ID0 )=87, 18400 ). holdsAt( appearance( grp_ID0 )=visible, 18400 ). % Frame number: 461 holdsAt( orientation( grp_ID0 )=87, 18440 ). holdsAt( appearance( grp_ID0 )=visible, 18440 ). % Frame number: 462 holdsAt( orientation( grp_ID0 )=87, 18480 ). holdsAt( appearance( grp_ID0 )=visible, 18480 ). % Frame number: 463 holdsAt( orientation( grp_ID0 )=90, 18520 ). holdsAt( appearance( grp_ID0 )=visible, 18520 ). % Frame number: 464 holdsAt( orientation( grp_ID0 )=90, 18560 ). holdsAt( appearance( grp_ID0 )=visible, 18560 ). % Frame number: 465 holdsAt( orientation( grp_ID0 )=90, 18600 ). holdsAt( appearance( grp_ID0 )=visible, 18600 ). % Frame number: 466 holdsAt( orientation( grp_ID0 )=90, 18640 ). holdsAt( appearance( grp_ID0 )=visible, 18640 ). % Frame number: 467 holdsAt( orientation( grp_ID0 )=90, 18680 ). holdsAt( appearance( grp_ID0 )=visible, 18680 ). % Frame number: 468 holdsAt( orientation( grp_ID0 )=90, 18720 ). holdsAt( appearance( grp_ID0 )=visible, 18720 ). % Frame number: 469 holdsAt( orientation( grp_ID0 )=95, 18760 ). holdsAt( appearance( grp_ID0 )=visible, 18760 ). % Frame number: 470 holdsAt( orientation( grp_ID0 )=95, 18800 ). holdsAt( appearance( grp_ID0 )=visible, 18800 ). % Frame number: 471 holdsAt( orientation( grp_ID0 )=98, 18840 ). holdsAt( appearance( grp_ID0 )=visible, 18840 ). % Frame number: 472 holdsAt( orientation( grp_ID0 )=98, 18880 ). holdsAt( appearance( grp_ID0 )=visible, 18880 ). % Frame number: 473 holdsAt( orientation( grp_ID0 )=98, 18920 ). holdsAt( appearance( grp_ID0 )=visible, 18920 ). % Frame number: 474 holdsAt( orientation( grp_ID0 )=100, 18960 ). holdsAt( appearance( grp_ID0 )=visible, 18960 ). % Frame number: 475 holdsAt( orientation( grp_ID0 )=100, 19000 ). holdsAt( appearance( grp_ID0 )=visible, 19000 ). % Frame number: 476 holdsAt( orientation( grp_ID0 )=100, 19040 ). holdsAt( appearance( grp_ID0 )=visible, 19040 ). % Frame number: 477 holdsAt( orientation( grp_ID0 )=100, 19080 ). holdsAt( appearance( grp_ID0 )=visible, 19080 ). % Frame number: 478 holdsAt( orientation( grp_ID0 )=100, 19120 ). holdsAt( appearance( grp_ID0 )=visible, 19120 ). % Frame number: 479 holdsAt( orientation( grp_ID0 )=100, 19160 ). holdsAt( appearance( grp_ID0 )=visible, 19160 ). % Frame number: 480 holdsAt( orientation( grp_ID0 )=103, 19200 ). holdsAt( appearance( grp_ID0 )=visible, 19200 ). % Frame number: 481 holdsAt( orientation( grp_ID0 )=103, 19240 ). holdsAt( appearance( grp_ID0 )=visible, 19240 ). % Frame number: 482 holdsAt( orientation( grp_ID0 )=103, 19280 ). holdsAt( appearance( grp_ID0 )=visible, 19280 ). % Frame number: 483 holdsAt( orientation( grp_ID0 )=103, 19320 ). holdsAt( appearance( grp_ID0 )=visible, 19320 ). % Frame number: 484 holdsAt( orientation( grp_ID0 )=103, 19360 ). holdsAt( appearance( grp_ID0 )=visible, 19360 ). % Frame number: 485 holdsAt( orientation( grp_ID0 )=103, 19400 ). holdsAt( appearance( grp_ID0 )=visible, 19400 ). % Frame number: 486 holdsAt( orientation( grp_ID0 )=103, 19440 ). holdsAt( appearance( grp_ID0 )=visible, 19440 ). % Frame number: 487 holdsAt( orientation( grp_ID0 )=103, 19480 ). holdsAt( appearance( grp_ID0 )=visible, 19480 ). % Frame number: 488 holdsAt( orientation( grp_ID0 )=106, 19520 ). holdsAt( appearance( grp_ID0 )=visible, 19520 ). % Frame number: 489 holdsAt( orientation( grp_ID0 )=106, 19560 ). holdsAt( appearance( grp_ID0 )=visible, 19560 ). % Frame number: 490 holdsAt( orientation( grp_ID0 )=106, 19600 ). holdsAt( appearance( grp_ID0 )=visible, 19600 ). % Frame number: 491 holdsAt( orientation( grp_ID0 )=106, 19640 ). holdsAt( appearance( grp_ID0 )=visible, 19640 ). % Frame number: 492 holdsAt( orientation( grp_ID0 )=106, 19680 ). holdsAt( appearance( grp_ID0 )=visible, 19680 ). % Frame number: 493 holdsAt( orientation( grp_ID0 )=106, 19720 ). holdsAt( appearance( grp_ID0 )=visible, 19720 ). % Frame number: 494 holdsAt( orientation( grp_ID0 )=106, 19760 ). holdsAt( appearance( grp_ID0 )=visible, 19760 ). % Frame number: 495 holdsAt( orientation( grp_ID0 )=100, 19800 ). holdsAt( appearance( grp_ID0 )=visible, 19800 ). % Frame number: 496 holdsAt( orientation( grp_ID0 )=100, 19840 ). holdsAt( appearance( grp_ID0 )=visible, 19840 ). % Frame number: 497 holdsAt( orientation( grp_ID0 )=100, 19880 ). holdsAt( appearance( grp_ID0 )=visible, 19880 ). % Frame number: 498 holdsAt( orientation( grp_ID0 )=100, 19920 ). holdsAt( appearance( grp_ID0 )=visible, 19920 ). % Frame number: 499 holdsAt( orientation( grp_ID0 )=100, 19960 ). holdsAt( appearance( grp_ID0 )=visible, 19960 ). % Frame number: 500 holdsAt( orientation( grp_ID0 )=100, 20000 ). holdsAt( appearance( grp_ID0 )=visible, 20000 ). % Frame number: 501 holdsAt( orientation( grp_ID0 )=100, 20040 ). holdsAt( appearance( grp_ID0 )=visible, 20040 ). % Frame number: 502 holdsAt( orientation( grp_ID0 )=100, 20080 ). holdsAt( appearance( grp_ID0 )=visible, 20080 ). % Frame number: 503 holdsAt( orientation( grp_ID0 )=100, 20120 ). holdsAt( appearance( grp_ID0 )=visible, 20120 ). % Frame number: 504 holdsAt( orientation( grp_ID0 )=100, 20160 ). holdsAt( appearance( grp_ID0 )=visible, 20160 ). % Frame number: 505 holdsAt( orientation( grp_ID0 )=100, 20200 ). holdsAt( appearance( grp_ID0 )=visible, 20200 ). % Frame number: 506 holdsAt( orientation( grp_ID0 )=100, 20240 ). holdsAt( appearance( grp_ID0 )=visible, 20240 ). % Frame number: 507 holdsAt( orientation( grp_ID0 )=100, 20280 ). holdsAt( appearance( grp_ID0 )=visible, 20280 ). % Frame number: 508 holdsAt( orientation( grp_ID0 )=100, 20320 ). holdsAt( appearance( grp_ID0 )=visible, 20320 ). % Frame number: 509 holdsAt( orientation( grp_ID0 )=100, 20360 ). holdsAt( appearance( grp_ID0 )=visible, 20360 ). % Frame number: 510 holdsAt( orientation( grp_ID0 )=100, 20400 ). holdsAt( appearance( grp_ID0 )=visible, 20400 ). % Frame number: 511 holdsAt( orientation( grp_ID0 )=100, 20440 ). holdsAt( appearance( grp_ID0 )=visible, 20440 ). % Frame number: 512 holdsAt( orientation( grp_ID0 )=100, 20480 ). holdsAt( appearance( grp_ID0 )=visible, 20480 ). % Frame number: 513 holdsAt( orientation( grp_ID0 )=100, 20520 ). holdsAt( appearance( grp_ID0 )=visible, 20520 ). % Frame number: 514 holdsAt( orientation( grp_ID0 )=100, 20560 ). holdsAt( appearance( grp_ID0 )=visible, 20560 ). % Frame number: 515 holdsAt( orientation( grp_ID0 )=100, 20600 ). holdsAt( appearance( grp_ID0 )=visible, 20600 ). % Frame number: 516 holdsAt( orientation( grp_ID0 )=100, 20640 ). holdsAt( appearance( grp_ID0 )=disappear, 20640 ). % Frame number: 945 holdsAt( orientation( grp_ID1 )=149, 37800 ). holdsAt( appearance( grp_ID1 )=appear, 37800 ). % Frame number: 946 holdsAt( orientation( grp_ID1 )=149, 37840 ). holdsAt( appearance( grp_ID1 )=visible, 37840 ). % Frame number: 947 holdsAt( orientation( grp_ID1 )=149, 37880 ). holdsAt( appearance( grp_ID1 )=visible, 37880 ). % Frame number: 948 holdsAt( orientation( grp_ID1 )=149, 37920 ). holdsAt( appearance( grp_ID1 )=visible, 37920 ). % Frame number: 949 holdsAt( orientation( grp_ID1 )=149, 37960 ). holdsAt( appearance( grp_ID1 )=visible, 37960 ). % Frame number: 950 holdsAt( orientation( grp_ID1 )=149, 38000 ). holdsAt( appearance( grp_ID1 )=visible, 38000 ). % Frame number: 951 holdsAt( orientation( grp_ID1 )=136, 38040 ). holdsAt( appearance( grp_ID1 )=visible, 38040 ). % Frame number: 952 holdsAt( orientation( grp_ID1 )=136, 38080 ). holdsAt( appearance( grp_ID1 )=visible, 38080 ). % Frame number: 953 holdsAt( orientation( grp_ID1 )=136, 38120 ). holdsAt( appearance( grp_ID1 )=visible, 38120 ). % Frame number: 954 holdsAt( orientation( grp_ID1 )=136, 38160 ). holdsAt( appearance( grp_ID1 )=visible, 38160 ). % Frame number: 955 holdsAt( orientation( grp_ID1 )=136, 38200 ). holdsAt( appearance( grp_ID1 )=visible, 38200 ). % Frame number: 956 holdsAt( orientation( grp_ID1 )=136, 38240 ). holdsAt( appearance( grp_ID1 )=visible, 38240 ). % Frame number: 957 holdsAt( orientation( grp_ID1 )=136, 38280 ). holdsAt( appearance( grp_ID1 )=visible, 38280 ). % Frame number: 958 holdsAt( orientation( grp_ID1 )=136, 38320 ). holdsAt( appearance( grp_ID1 )=visible, 38320 ). % Frame number: 959 holdsAt( orientation( grp_ID1 )=136, 38360 ). holdsAt( appearance( grp_ID1 )=visible, 38360 ). % Frame number: 960 holdsAt( orientation( grp_ID1 )=136, 38400 ). holdsAt( appearance( grp_ID1 )=visible, 38400 ). % Frame number: 961 holdsAt( orientation( grp_ID1 )=136, 38440 ). holdsAt( appearance( grp_ID1 )=visible, 38440 ). % Frame number: 962 holdsAt( orientation( grp_ID1 )=136, 38480 ). holdsAt( appearance( grp_ID1 )=visible, 38480 ). % Frame number: 963 holdsAt( orientation( grp_ID1 )=136, 38520 ). holdsAt( appearance( grp_ID1 )=visible, 38520 ). % Frame number: 964 holdsAt( orientation( grp_ID1 )=136, 38560 ). holdsAt( appearance( grp_ID1 )=visible, 38560 ). % Frame number: 965 holdsAt( orientation( grp_ID1 )=136, 38600 ). holdsAt( appearance( grp_ID1 )=visible, 38600 ). % Frame number: 966 holdsAt( orientation( grp_ID1 )=140, 38640 ). holdsAt( appearance( grp_ID1 )=visible, 38640 ). % Frame number: 967 holdsAt( orientation( grp_ID1 )=140, 38680 ). holdsAt( appearance( grp_ID1 )=visible, 38680 ). % Frame number: 968 holdsAt( orientation( grp_ID1 )=140, 38720 ). holdsAt( appearance( grp_ID1 )=visible, 38720 ). % Frame number: 969 holdsAt( orientation( grp_ID1 )=140, 38760 ). holdsAt( appearance( grp_ID1 )=visible, 38760 ). % Frame number: 970 holdsAt( orientation( grp_ID1 )=140, 38800 ). holdsAt( appearance( grp_ID1 )=visible, 38800 ). % Frame number: 971 holdsAt( orientation( grp_ID1 )=140, 38840 ). holdsAt( appearance( grp_ID1 )=visible, 38840 ). % Frame number: 972 holdsAt( orientation( grp_ID1 )=140, 38880 ). holdsAt( appearance( grp_ID1 )=visible, 38880 ). % Frame number: 973 holdsAt( orientation( grp_ID1 )=140, 38920 ). holdsAt( appearance( grp_ID1 )=visible, 38920 ). % Frame number: 974 holdsAt( orientation( grp_ID1 )=144, 38960 ). holdsAt( appearance( grp_ID1 )=visible, 38960 ). % Frame number: 975 holdsAt( orientation( grp_ID1 )=143, 39000 ). holdsAt( appearance( grp_ID1 )=visible, 39000 ). % Frame number: 976 holdsAt( orientation( grp_ID1 )=144, 39040 ). holdsAt( appearance( grp_ID1 )=visible, 39040 ). % Frame number: 977 holdsAt( orientation( grp_ID1 )=148, 39080 ). holdsAt( appearance( grp_ID1 )=visible, 39080 ). % Frame number: 978 holdsAt( orientation( grp_ID1 )=148, 39120 ). holdsAt( appearance( grp_ID1 )=visible, 39120 ). % Frame number: 979 holdsAt( orientation( grp_ID1 )=146, 39160 ). holdsAt( appearance( grp_ID1 )=visible, 39160 ). % Frame number: 980 holdsAt( orientation( grp_ID1 )=151, 39200 ). holdsAt( appearance( grp_ID1 )=visible, 39200 ). % Frame number: 981 holdsAt( orientation( grp_ID1 )=153, 39240 ). holdsAt( appearance( grp_ID1 )=visible, 39240 ). % Frame number: 982 holdsAt( orientation( grp_ID1 )=156, 39280 ). holdsAt( appearance( grp_ID1 )=visible, 39280 ). % Frame number: 983 holdsAt( orientation( grp_ID1 )=154, 39320 ). holdsAt( appearance( grp_ID1 )=visible, 39320 ). % Frame number: 984 holdsAt( orientation( grp_ID1 )=154, 39360 ). holdsAt( appearance( grp_ID1 )=visible, 39360 ). % Frame number: 985 holdsAt( orientation( grp_ID1 )=154, 39400 ). holdsAt( appearance( grp_ID1 )=visible, 39400 ). % Frame number: 986 holdsAt( orientation( grp_ID1 )=154, 39440 ). holdsAt( appearance( grp_ID1 )=visible, 39440 ). % Frame number: 987 holdsAt( orientation( grp_ID1 )=154, 39480 ). holdsAt( appearance( grp_ID1 )=visible, 39480 ). % Frame number: 988 holdsAt( orientation( grp_ID1 )=154, 39520 ). holdsAt( appearance( grp_ID1 )=visible, 39520 ). % Frame number: 989 holdsAt( orientation( grp_ID1 )=154, 39560 ). holdsAt( appearance( grp_ID1 )=visible, 39560 ). % Frame number: 990 holdsAt( orientation( grp_ID1 )=154, 39600 ). holdsAt( appearance( grp_ID1 )=visible, 39600 ). % Frame number: 991 holdsAt( orientation( grp_ID1 )=154, 39640 ). holdsAt( appearance( grp_ID1 )=visible, 39640 ). % Frame number: 992 holdsAt( orientation( grp_ID1 )=154, 39680 ). holdsAt( appearance( grp_ID1 )=visible, 39680 ). % Frame number: 993 holdsAt( orientation( grp_ID1 )=154, 39720 ). holdsAt( appearance( grp_ID1 )=visible, 39720 ). % Frame number: 994 holdsAt( orientation( grp_ID1 )=154, 39760 ). holdsAt( appearance( grp_ID1 )=visible, 39760 ). % Frame number: 995 holdsAt( orientation( grp_ID1 )=154, 39800 ). holdsAt( appearance( grp_ID1 )=visible, 39800 ). % Frame number: 996 holdsAt( orientation( grp_ID1 )=154, 39840 ). holdsAt( appearance( grp_ID1 )=disappear, 39840 ).
JasonFil/Prob-EC
dataset/strong-noise/14-LeftBag/lb1gtAppearenceGrp.pl
Perl
bsd-3-clause
65,989
# !!!!!!! DO NOT EDIT THIS FILE !!!!!!! # This file is machine-generated by mktables from the Unicode # database, Version 6.1.0. Any changes made here will be lost! # !!!!!!! INTERNAL PERL USE ONLY !!!!!!! # This file is for internal use by core Perl only. The format and even the # name or existence of this file are subject to change without notice. Don't # use it directly. return <<'END'; 0726 END
Dokaponteam/ITF_Project
xampp/perl/lib/unicore/lib/Jg/Pe.pl
Perl
mit
418
package File::Spec::Unix; use strict; use vars qw($VERSION); $VERSION = '3.2701'; =head1 NAME File::Spec::Unix - File::Spec for Unix, base for other File::Spec modules =head1 SYNOPSIS require File::Spec::Unix; # Done automatically by File::Spec =head1 DESCRIPTION Methods for manipulating file specifications. Other File::Spec modules, such as File::Spec::Mac, inherit from File::Spec::Unix and override specific methods. =head1 METHODS =over 2 =item canonpath() No physical check on the filesystem, but a logical cleanup of a path. On UNIX eliminates successive slashes and successive "/.". $cpath = File::Spec->canonpath( $path ) ; Note that this does *not* collapse F<x/../y> sections into F<y>. This is by design. If F</foo> on your system is a symlink to F</bar/baz>, then F</foo/../quux> is actually F</bar/quux>, not F</quux> as a naive F<../>-removal would give you. If you want to do this kind of processing, you probably want C<Cwd>'s C<realpath()> function to actually traverse the filesystem cleaning up paths like this. =cut sub canonpath { my ($self,$path) = @_; return unless defined $path; # Handle POSIX-style node names beginning with double slash (qnx, nto) # (POSIX says: "a pathname that begins with two successive slashes # may be interpreted in an implementation-defined manner, although # more than two leading slashes shall be treated as a single slash.") my $node = ''; my $double_slashes_special = $^O eq 'qnx' || $^O eq 'nto'; if ( $double_slashes_special && $path =~ s{^(//[^/]+)(?:/|\z)}{/}s ) { $node = $1; } # This used to be # $path =~ s|/+|/|g unless ($^O eq 'cygwin'); # but that made tests 29, 30, 35, 46, and 213 (as of #13272) to fail # (Mainly because trailing "" directories didn't get stripped). # Why would cygwin avoid collapsing multiple slashes into one? --jhi $path =~ s|/{2,}|/|g; # xx////xx -> xx/xx $path =~ s{(?:/\.)+(?:/|\z)}{/}g; # xx/././xx -> xx/xx $path =~ s|^(?:\./)+||s unless $path eq "./"; # ./xx -> xx $path =~ s|^/(?:\.\./)+|/|; # /../../xx -> xx $path =~ s|^/\.\.$|/|; # /.. -> / $path =~ s|/\z|| unless $path eq "/"; # xx/ -> xx return "$node$path"; } =item catdir() Concatenate two or more directory names to form a complete path ending with a directory. But remove the trailing slash from the resulting string, because it doesn't look good, isn't necessary and confuses OS2. Of course, if this is the root directory, don't cut off the trailing slash :-) =cut sub catdir { my $self = shift; $self->canonpath(join('/', @_, '')); # '' because need a trailing '/' } =item catfile Concatenate one or more directory names and a filename to form a complete path ending with a filename =cut sub catfile { my $self = shift; my $file = $self->canonpath(pop @_); return $file unless @_; my $dir = $self->catdir(@_); $dir .= "/" unless substr($dir,-1) eq "/"; return $dir.$file; } =item curdir Returns a string representation of the current directory. "." on UNIX. =cut sub curdir () { '.' } =item devnull Returns a string representation of the null device. "/dev/null" on UNIX. =cut sub devnull () { '/dev/null' } =item rootdir Returns a string representation of the root directory. "/" on UNIX. =cut sub rootdir () { '/' } =item tmpdir Returns a string representation of the first writable directory from the following list or the current directory if none from the list are writable: $ENV{TMPDIR} /tmp Since perl 5.8.0, if running under taint mode, and if $ENV{TMPDIR} is tainted, it is not used. =cut my $tmpdir; sub _tmpdir { return $tmpdir if defined $tmpdir; my $self = shift; my @dirlist = @_; { no strict 'refs'; if (${"\cTAINT"}) { # Check for taint mode on perl >= 5.8.0 require Scalar::Util; @dirlist = grep { ! Scalar::Util::tainted($_) } @dirlist; } } foreach (@dirlist) { next unless defined && -d && -w _; $tmpdir = $_; last; } $tmpdir = $self->curdir unless defined $tmpdir; $tmpdir = defined $tmpdir && $self->canonpath($tmpdir); return $tmpdir; } sub tmpdir { return $tmpdir if defined $tmpdir; $tmpdir = $_[0]->_tmpdir( $ENV{TMPDIR}, "/tmp" ); } =item updir Returns a string representation of the parent directory. ".." on UNIX. =cut sub updir () { '..' } =item no_upwards Given a list of file names, strip out those that refer to a parent directory. (Does not strip symlinks, only '.', '..', and equivalents.) =cut sub no_upwards { my $self = shift; return grep(!/^\.{1,2}\z/s, @_); } =item case_tolerant Returns a true or false value indicating, respectively, that alphabetic is not or is significant when comparing file specifications. =cut sub case_tolerant () { 0 } =item file_name_is_absolute Takes as argument a path and returns true if it is an absolute path. This does not consult the local filesystem on Unix, Win32, OS/2 or Mac OS (Classic). It does consult the working environment for VMS (see L<File::Spec::VMS/file_name_is_absolute>). =cut sub file_name_is_absolute { my ($self,$file) = @_; return scalar($file =~ m:^/:s); } =item path Takes no argument, returns the environment variable PATH as an array. =cut sub path { return () unless exists $ENV{PATH}; my @path = split(':', $ENV{PATH}); foreach (@path) { $_ = '.' if $_ eq '' } return @path; } =item join join is the same as catfile. =cut sub join { my $self = shift; return $self->catfile(@_); } =item splitpath ($volume,$directories,$file) = File::Spec->splitpath( $path ); ($volume,$directories,$file) = File::Spec->splitpath( $path, $no_file ); Splits a path into volume, directory, and filename portions. On systems with no concept of volume, returns '' for volume. For systems with no syntax differentiating filenames from directories, assumes that the last file is a path unless $no_file is true or a trailing separator or /. or /.. is present. On Unix this means that $no_file true makes this return ( '', $path, '' ). The directory portion may or may not be returned with a trailing '/'. The results can be passed to L</catpath()> to get back a path equivalent to (usually identical to) the original path. =cut sub splitpath { my ($self,$path, $nofile) = @_; my ($volume,$directory,$file) = ('','',''); if ( $nofile ) { $directory = $path; } else { $path =~ m|^ ( (?: .* / (?: \.\.?\z )? )? ) ([^/]*) |xs; $directory = $1; $file = $2; } return ($volume,$directory,$file); } =item splitdir The opposite of L</catdir()>. @dirs = File::Spec->splitdir( $directories ); $directories must be only the directory portion of the path on systems that have the concept of a volume or that have path syntax that differentiates files from directories. Unlike just splitting the directories on the separator, empty directory names (C<''>) can be returned, because these are significant on some OSs. On Unix, File::Spec->splitdir( "/a/b//c/" ); Yields: ( '', 'a', 'b', '', 'c', '' ) =cut sub splitdir { return split m|/|, $_[1], -1; # Preserve trailing fields } =item catpath() Takes volume, directory and file portions and returns an entire path. Under Unix, $volume is ignored, and directory and file are concatenated. A '/' is inserted if needed (though if the directory portion doesn't start with '/' it is not added). On other OSs, $volume is significant. =cut sub catpath { my ($self,$volume,$directory,$file) = @_; if ( $directory ne '' && $file ne '' && substr( $directory, -1 ) ne '/' && substr( $file, 0, 1 ) ne '/' ) { $directory .= "/$file" ; } else { $directory .= $file ; } return $directory ; } =item abs2rel Takes a destination path and an optional base path returns a relative path from the base path to the destination path: $rel_path = File::Spec->abs2rel( $path ) ; $rel_path = File::Spec->abs2rel( $path, $base ) ; If $base is not present or '', then L<cwd()|Cwd> is used. If $base is relative, then it is converted to absolute form using L</rel2abs()>. This means that it is taken to be relative to L<cwd()|Cwd>. On systems that have a grammar that indicates filenames, this ignores the $base filename. Otherwise all path components are assumed to be directories. If $path is relative, it is converted to absolute form using L</rel2abs()>. This means that it is taken to be relative to L<cwd()|Cwd>. No checks against the filesystem are made. On VMS, there is interaction with the working environment, as logicals and macros are expanded. Based on code written by Shigio Yamaguchi. =cut sub abs2rel { my($self,$path,$base) = @_; $base = $self->_cwd() unless defined $base and length $base; ($path, $base) = map $self->canonpath($_), $path, $base; if (grep $self->file_name_is_absolute($_), $path, $base) { ($path, $base) = map $self->rel2abs($_), $path, $base; } else { # save a couple of cwd()s if both paths are relative ($path, $base) = map $self->catdir('/', $_), $path, $base; } my ($path_volume) = $self->splitpath($path, 1); my ($base_volume) = $self->splitpath($base, 1); # Can't relativize across volumes return $path unless $path_volume eq $base_volume; my $path_directories = ($self->splitpath($path, 1))[1]; my $base_directories = ($self->splitpath($base, 1))[1]; # For UNC paths, the user might give a volume like //foo/bar that # strictly speaking has no directory portion. Treat it as if it # had the root directory for that volume. if (!length($base_directories) and $self->file_name_is_absolute($base)) { $base_directories = $self->rootdir; } # Now, remove all leading components that are the same my @pathchunks = $self->splitdir( $path_directories ); my @basechunks = $self->splitdir( $base_directories ); if ($base_directories eq $self->rootdir) { shift @pathchunks; return $self->canonpath( $self->catpath('', $self->catdir( @pathchunks ), '') ); } while (@pathchunks && @basechunks && $self->_same($pathchunks[0], $basechunks[0])) { shift @pathchunks ; shift @basechunks ; } return $self->curdir unless @pathchunks || @basechunks; # $base now contains the directories the resulting relative path # must ascend out of before it can descend to $path_directory. my $result_dirs = $self->catdir( ($self->updir) x @basechunks, @pathchunks ); return $self->canonpath( $self->catpath('', $result_dirs, '') ); } sub _same { $_[1] eq $_[2]; } =item rel2abs() Converts a relative path to an absolute path. $abs_path = File::Spec->rel2abs( $path ) ; $abs_path = File::Spec->rel2abs( $path, $base ) ; If $base is not present or '', then L<cwd()|Cwd> is used. If $base is relative, then it is converted to absolute form using L</rel2abs()>. This means that it is taken to be relative to L<cwd()|Cwd>. On systems that have a grammar that indicates filenames, this ignores the $base filename. Otherwise all path components are assumed to be directories. If $path is absolute, it is cleaned up and returned using L</canonpath()>. No checks against the filesystem are made. On VMS, there is interaction with the working environment, as logicals and macros are expanded. Based on code written by Shigio Yamaguchi. =cut sub rel2abs { my ($self,$path,$base ) = @_; # Clean up $path if ( ! $self->file_name_is_absolute( $path ) ) { # Figure out the effective $base and clean it up. if ( !defined( $base ) || $base eq '' ) { $base = $self->_cwd(); } elsif ( ! $self->file_name_is_absolute( $base ) ) { $base = $self->rel2abs( $base ) ; } else { $base = $self->canonpath( $base ) ; } # Glom them together $path = $self->catdir( $base, $path ) ; } return $self->canonpath( $path ) ; } =back =head1 COPYRIGHT Copyright (c) 2004 by the Perl 5 Porters. 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 L<File::Spec> =cut # Internal routine to File::Spec, no point in making this public since # it is the standard Cwd interface. Most of the platform-specific # File::Spec subclasses use this. sub _cwd { require Cwd; Cwd::getcwd(); } # Internal method to reduce xx\..\yy -> yy sub _collapse { my($fs, $path) = @_; my $updir = $fs->updir; my $curdir = $fs->curdir; my($vol, $dirs, $file) = $fs->splitpath($path); my @dirs = $fs->splitdir($dirs); pop @dirs if @dirs && $dirs[-1] eq ''; my @collapsed; foreach my $dir (@dirs) { if( $dir eq $updir and # if we have an updir @collapsed and # and something to collapse length $collapsed[-1] and # and its not the rootdir $collapsed[-1] ne $updir and # nor another updir $collapsed[-1] ne $curdir # nor the curdir ) { # then pop @collapsed; # collapse } else { # else push @collapsed, $dir; # just hang onto it } } return $fs->catpath($vol, $fs->catdir(@collapsed), $file ); } 1;
leighpauls/k2cro4
third_party/cygwin/lib/perl5/vendor_perl/5.10/i686-cygwin/File/Spec/Unix.pm
Perl
bsd-3-clause
13,807
#!/usr/bin/perl use CGI qw/ :standard /; use File::Temp qw/ tempfile tempdir /; # my $spellercss = '/speller/spellerStyle.css'; # by FredCK my $spellercss = '../spellerStyle.css'; # by FredCK # my $wordWindowSrc = '/speller/wordWindow.js'; # by FredCK my $wordWindowSrc = '../wordWindow.js'; # by FredCK my @textinputs = param( 'textinputs[]' ); # array # my $aspell_cmd = 'aspell'; # by FredCK (for Linux) my $aspell_cmd = '"C:\Program Files\Aspell\bin\aspell.exe"'; # by FredCK (for Windows) my $lang = 'en_US'; # my $aspell_opts = "-a --lang=$lang --encoding=utf-8"; # by FredCK my $aspell_opts = "-a --lang=$lang --encoding=utf-8 -H"; # by FredCK my $input_separator = "A"; # set the 'wordtext' JavaScript variable to the submitted text. sub printTextVar { for( my $i = 0; $i <= $#textinputs; $i++ ) { print "textinputs[$i] = decodeURIComponent('" . escapeQuote( $textinputs[$i] ) . "')\n"; } } sub printTextIdxDecl { my $idx = shift; print "words[$idx] = [];\n"; print "suggs[$idx] = [];\n"; } sub printWordsElem { my( $textIdx, $wordIdx, $word ) = @_; print "words[$textIdx][$wordIdx] = '" . escapeQuote( $word ) . "';\n"; } sub printSuggsElem { my( $textIdx, $wordIdx, @suggs ) = @_; print "suggs[$textIdx][$wordIdx] = ["; for my $i ( 0..$#suggs ) { print "'" . escapeQuote( $suggs[$i] ) . "'"; if( $i < $#suggs ) { print ", "; } } print "];\n"; } sub printCheckerResults { my $textInputIdx = -1; my $wordIdx = 0; my $unhandledText; # create temp file my $dir = tempdir( CLEANUP => 1 ); my( $fh, $tmpfilename ) = tempfile( DIR => $dir ); # temp file was created properly? # open temp file, add the submitted text. for( my $i = 0; $i <= $#textinputs; $i++ ) { $text = url_decode( $textinputs[$i] ); @lines = split( /\n/, $text ); print $fh "\%\n"; # exit terse mode print $fh "^$input_separator\n"; print $fh "!\n"; # enter terse mode for my $line ( @lines ) { # use carat on each line to escape possible aspell commands print $fh "^$line\n"; } } # exec aspell command my $cmd = "$aspell_cmd $aspell_opts < $tmpfilename 2>&1"; open ASPELL, "$cmd |" or handleError( "Could not execute `$cmd`\\n$!" ) and return; # parse each line of aspell return for my $ret ( <ASPELL> ) { chomp( $ret ); # if '&', then not in dictionary but has suggestions # if '#', then not in dictionary and no suggestions # if '*', then it is a delimiter between text inputs if( $ret =~ /^\*/ ) { $textInputIdx++; printTextIdxDecl( $textInputIdx ); $wordIdx = 0; } elsif( $ret =~ /^(&|#)/ ) { my @tokens = split( " ", $ret, 5 ); printWordsElem( $textInputIdx, $wordIdx, $tokens[1] ); my @suggs = (); if( $tokens[4] ) { @suggs = split( ", ", $tokens[4] ); } printSuggsElem( $textInputIdx, $wordIdx, @suggs ); $wordIdx++; } else { $unhandledText .= $ret; } } close ASPELL or handleError( "Error executing `$cmd`\\n$unhandledText" ) and return; } sub escapeQuote { my $str = shift; $str =~ s/'/\\'/g; return $str; } sub handleError { my $err = shift; print "error = '" . escapeQuote( $err ) . "';\n"; } sub url_decode { local $_ = @_ ? shift : $_; defined or return; # change + signs to spaces tr/+/ /; # change hex escapes to the proper characters s/%([a-fA-F0-9]{2})/pack "H2", $1/eg; return $_; } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Display HTML # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # print <<EOF; Content-type: text/html; charset=utf-8 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" type="text/css" href="$spellercss"/> <script src="$wordWindowSrc"></script> <script type="text/javascript"> var suggs = new Array(); var words = new Array(); var textinputs = new Array(); var error; EOF printTextVar(); printCheckerResults(); print <<EOF; var wordWindowObj = new wordWindow(); wordWindowObj.originalSpellings = words; wordWindowObj.suggestions = suggs; wordWindowObj.textInputs = textinputs; function init_spell() { // check if any error occured during server-side processing if( error ) { alert( error ); } else { // call the init_spell() function in the parent frameset if (parent.frames.length) { parent.init_spell( wordWindowObj ); } else { error = "This page was loaded outside of a frameset. "; error += "It might not display properly"; alert( error ); } } } </script> </head> <body onLoad="init_spell();"> <script type="text/javascript"> wordWindowObj.writeBody(); </script> </body> </html> EOF
WilliamGoossen/epsos-common-components.gnomonportal
webapps/ROOT/html/js/editor/fckeditor/editor/dialog/fck_spellerpages/spellerpages/server-scripts/spellchecker.pl
Perl
apache-2.0
4,647
package CXGN::Apache::Registry; use strict; use warnings; use base qw(ModPerl::RegistryPrefork); use SGN::Context; # add a global $c variable to the top of every script for the context # object my $cxgn_script_header = <<'EOC'; our $c = SGN::Context->instance; EOC sub get_mark_line { my $self = shift; return $cxgn_script_header.$self->SUPER::get_mark_line(@_); } sub read_script { my $self = shift; # keep site die handlers from interfering with proper 404 and 403 # error handling local $SIG{__DIE__} = undef; return $self->SUPER::read_script(@_); } 1; __END__ =head1 NAME CXGN::Apache::Registry - slightly customized subclass of L<ModPerl::RegistryPrefork> =head1 DESCRIPTION Adds a global our $c = SGN::Context->instance to the beginning of every script. Localizes C<$SIG{__DIE__}> when reading script files from disk, to enable proper 404 and 403 handling in the presence of custom C<$SIG{__DIE__}> handlers. =head1 Authors Robert Buels =cut
solgenomics/sgn
lib/CXGN/Apache/Registry.pm
Perl
mit
995
prune_([X|L],[X|R]):- delete_(X,L,W), prune_(W,R). prune_([],[]).
shivekkhurana/learning
prolog/prune.pl
Perl
mit
74
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ____ ____ \ \ / / \ \ ____ / / \ \/ \/ / \ /\ / BRACHYLOG \ / \ / A terse declarative logic programming language / \ / \ / \/ \ Written by Julien Cumin - 2017 / /\____/\ \ https://github.com/JCumin/Brachylog / / ___ \ \ /___/ /__/ \___\ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ :- module(metapredicates, [brachylog_meta_accumulate/6, brachylog_meta_bagof/6, brachylog_meta_count/6, brachylog_meta_declare/6, brachylog_meta_existence/6, brachylog_meta_find/6, brachylog_meta_groupby/6, brachylog_meta_head/6, brachylog_meta_iterate/6, brachylog_meta_leftfold/6, brachylog_meta_map/6, brachylog_meta_nonexistence/6, brachylog_meta_orderby/6, brachylog_meta_select/6, brachylog_meta_tail/6, brachylog_meta_unique/6, brachylog_meta_verify/6, brachylog_meta_zip/6 ]). :- use_module(library(clpfd)). :- use_module(predicates). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BRACHYLOG_META_ACCUMULATE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ brachylog_meta_accumulate(GlobalVariables, 'first', P, Sub, ['integer':I|Input], Output) :- ( Input = [Arg] -> true ; Input = Arg ), brachylog_meta_accumulate(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_accumulate(GlobalVariables, 'last', P, Sub, Input, Output) :- reverse(Input, ['integer':I|T]), ( T = [Arg] -> true ; reverse(T, Arg) ), brachylog_meta_accumulate(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_accumulate(GlobalVariables, 'default', P, Sub, Input, Output) :- brachylog_meta_accumulate(GlobalVariables, 'integer':1, P, Sub, Input, Output). brachylog_meta_accumulate(GlobalVariables, Sup, P, Sub, 'string':Input, Output) :- brachylog_meta_accumulate(GlobalVariables, Sup, P, Sub, ['string':Input], Output). brachylog_meta_accumulate(GlobalVariables, Sup, P, Sub, 'integer':Input, Output) :- brachylog_meta_accumulate(GlobalVariables, Sup, P, Sub, ['integer':Input], Output). brachylog_meta_accumulate(GlobalVariables, Sup, P, Sub, 'float':Input, Output) :- brachylog_meta_accumulate(GlobalVariables, Sup, P, Sub, ['float':Input], Output). brachylog_meta_accumulate(_, 'integer':0, _P, _Sub, Input, Input). brachylog_meta_accumulate(GlobalVariables, 'integer':I, P, Sub, Input, Output) :- I #> 0, is_brachylog_list(Input), ( GlobalVariables = 'ignore', call(P, Sub, Input, E) ; dif(GlobalVariables, 'ignore'), call(P, GlobalVariables, Sub, Input, E) ), J #= I - 1, append(Input, [E], F), brachylog_meta_accumulate(GlobalVariables, 'integer':J, P, Sub, F, Output). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BRACHYLOG_META_BAGOF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ brachylog_meta_bagof(GlobalVariables, 'first', P, Sub, ['integer':I|Input], Output) :- ( Input = [Arg] -> true ; Input = Arg ), brachylog_meta_bagof(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_bagof(GlobalVariables, 'last', P, Sub, Input, Output) :- reverse(Input, ['integer':I|T]), ( T = [Arg] -> true ; reverse(T, Arg) ), brachylog_meta_bagof(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_bagof(_, 'integer':0, _, _, _, []). brachylog_meta_bagof(GlobalVariables, 'default', P, Sub, Input, Output) :- bagof(X, ( GlobalVariables = 'ignore', call(P, Sub, Input, X) ; dif(GlobalVariables, 'ignore'), call(P, GlobalVariables, Sub, Input, X) ), Output). brachylog_meta_bagof(GlobalVariables, 'integer':I, P, Sub, Input, Output) :- I #> 0, bagof(X, call_firstn( ( GlobalVariables = 'ignore', call(P, Sub, Input, X) ; dif(GlobalVariables, 'ignore'), call(P, GlobalVariables, Sub, Input, X) ), I), Output). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BRACHYLOG_META_COUNT - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ brachylog_meta_count(GlobalVariables, 'first', P, Sub, ['integer':I|Input], Output) :- ( Input = [Arg] -> true ; Input = Arg ), brachylog_meta_count(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_count(GlobalVariables, 'last', P, Sub, Input, Output) :- reverse(Input, ['integer':I|T]), ( T = [Arg] -> true ; reverse(T, Arg) ), brachylog_meta_count(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_count(GlobalVariables, 'default', P, Sub, Input, Output) :- brachylog_meta_count(GlobalVariables, 'integer':0, P, Sub, Input, Output). brachylog_meta_count(GlobalVariables, 'integer':0, P, Sub, Input, Output) :- brachylog_meta_find(GlobalVariables, 'default', P, Sub, Input, E), brachylog_length('default', E, Output). brachylog_meta_count(GlobalVariables, 'integer':1, P, Sub, Input, Output) :- brachylog_meta_unique(GlobalVariables, 'default', P, Sub, Input, E), brachylog_length('default', E, Output). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BRACHYLOG_META_DECLARE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ brachylog_meta_declare(GlobalVariables, 'first', P, Sub, ['integer':I|Input], Output) :- ( Input = [Arg] -> true ; Input = Arg ), brachylog_meta_declare(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_declare(GlobalVariables, 'last', P, Sub, Input, Output) :- reverse(Input, ['integer':I|T]), ( T = [Arg] -> true ; reverse(T, Arg) ), brachylog_meta_declare(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_declare(GlobalVariables, 'default', P, Sub, [H,T], T) :- ( GlobalVariables = 'ignore', call(P, Sub, H, T) ; dif(GlobalVariables, 'ignore'), call(P, GlobalVariables, Sub, H, T) ). brachylog_meta_declare(GlobalVariables, 'integer':0, P, Sub, [H,T], [H,T]) :- ( GlobalVariables = 'ignore', call(P, Sub, H, T) ; dif(GlobalVariables, 'ignore'), call(P, GlobalVariables, Sub, H, T) ). brachylog_meta_declare(GlobalVariables, 'integer':1, P, Sub, [H,T], H) :- ( GlobalVariables = 'ignore', call(P, Sub, T, H) ; dif(GlobalVariables, 'ignore'), call(P, GlobalVariables, Sub, T, H) ). brachylog_meta_declare(GlobalVariables, 'integer':2, P, Sub, [H,T], [H,T]) :- ( GlobalVariables = 'ignore', call(P, Sub, T, H) ; dif(GlobalVariables, 'ignore'), call(P, GlobalVariables, Sub, T, H) ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BRACHYLOG_META_EXISTENCE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ brachylog_meta_existence(GlobalVariables, 'first', P, Sub, [I|Input], Arg) :- ( Input = [Arg] -> true ; Input = Arg ), brachylog_meta_existence(GlobalVariables, P, Sub, Arg, I). brachylog_meta_existence(GlobalVariables, 'last', P, Sub, Input, Arg) :- reverse(Input, [I|T]), ( T = [Arg] -> true ; reverse(T, Arg) ), brachylog_meta_existence(GlobalVariables, P, Sub, Arg, I). brachylog_meta_existence(GlobalVariables, 'integer':I, P, Sub, Input, Input) :- dif(I, 'default'), brachylog_meta_existence(GlobalVariables, P, Sub, Input, 'integer':I). brachylog_meta_existence(GlobalVariables, 'default', P, Sub, Input, Output) :- brachylog_meta_existence(GlobalVariables, P, Sub, Input, Output). brachylog_meta_existence(GlobalVariables, P, Sub, Input, Output) :- brachylog_in('default', Input, E), ( GlobalVariables = 'ignore', call(P, Sub, E, Output) ; dif(GlobalVariables, 'ignore'), call(P, GlobalVariables, Sub, E, Output) ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BRACHYLOG_META_FIND Credits to @false for call_firstf/2 and call_nth/2 http://stackoverflow.com/a/20866206/2554145 http://stackoverflow.com/a/11400256/2554145 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ brachylog_meta_find(GlobalVariables, 'first', P, Sub, ['integer':I|Input], Output) :- ( Input = [Arg] -> true ; Input = Arg ), brachylog_meta_find(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_find(GlobalVariables, 'last', P, Sub, Input, Output) :- reverse(Input, ['integer':I|T]), ( T = [Arg] -> true ; reverse(T, Arg) ), brachylog_meta_find(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_find(_, 'integer':0, _, _, _, []). brachylog_meta_find(GlobalVariables, 'default', P, Sub, Input, Output) :- findall(X, ( GlobalVariables = 'ignore', call(P, Sub, Input, X) ; dif(GlobalVariables, 'ignore'), call(P, GlobalVariables, Sub, Input, X) ), Output). brachylog_meta_find(GlobalVariables, 'integer':I, P, Sub, Input, Output) :- I #> 0, findall(X, call_firstn( ( GlobalVariables = 'ignore', call(P, Sub, Input, X) ; dif(GlobalVariables, 'ignore'), call(P, GlobalVariables, Sub, Input, X) ), I), Output). call_firstn(Goal_0, N) :- N + N mod 1 >= 0, % ensures that N >=0 and N is an integer call_nth(Goal_0, Nth), ( Nth == N -> ! ; true ). call_nth(Goal_0, C) :- State = count(0, _), Goal_0, arg(1, State, C1), C2 is C1+1, nb_setarg(1, State, C2), C = C2. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BRACHYLOG_META_GROUPBY - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ brachylog_meta_groupby(GlobalVariables, 'first', P, Sub, ['integer':I|Input], Output) :- ( Input = [Arg] -> true ; Input = Arg ), brachylog_meta_groupby(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_groupby(GlobalVariables, 'last', P, Sub, Input, Output) :- reverse(Input, ['integer':I|T]), ( T = [Arg] -> true ; reverse(T, Arg) ), brachylog_meta_groupby(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_groupby(GlobalVariables, 'default', P, Sub, Input, Output) :- ( is_brachylog_list(Input) -> FixedInput = Input ; brachylog_elements('default', Input, FixedInput) ), brachylog_meta_map(GlobalVariables, 'default', P, Sub, FixedInput, L), brachylog_zip('default', [L,Input], L2), brachylog_meta_groupby_group(L2, L3), maplist(brachylog_meta_groupby_tail, L3, Output). brachylog_meta_groupby_group(L, Gs) :- brachylog_meta_groupby_group(L, [], Gs). brachylog_meta_groupby_group([], Gs, Gs). brachylog_meta_groupby_group([[G,H]|T], TempGs, Gs) :- ( member(G:L, TempGs) -> reverse(L, RL), reverse([H|RL], L2), select(G:L, TempGs, G:L2, TempGs2) ; append(TempGs, [G:[H]], TempGs2) ), brachylog_meta_groupby_group(T, TempGs2, Gs). brachylog_meta_groupby_tail(_:T, T). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BRACHYLOG_META_HEAD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ brachylog_meta_head(GlobalVariables, 'first', P, Sub, ['integer':I|Input], Output) :- ( Input = [Arg] -> true ; Input = Arg ), brachylog_meta_head(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_head(GlobalVariables, 'last', P, Sub, Input, Output) :- reverse(Input, ['integer':I|T]), ( T = [Arg] -> true ; reverse(T, Arg) ), brachylog_meta_head(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_head(GlobalVariables, 'default', P, Sub, Input, Output) :- brachylog_meta_head(GlobalVariables, 'integer':1, P, Sub, Input, Output). brachylog_meta_head(_, 'integer':0, _, _, Input, Input). brachylog_meta_head(GlobalVariables, 'integer':I, P, Sub, Input, Output) :- I #> 0, brachylog_head('integer':I, Input, Heads), brachylog_behead('integer':I, Input, Tails), brachylog_meta_map(GlobalVariables, 'default', P, Sub, Heads, NewHeads), brachylog_concatenate('default', [NewHeads,Tails], Output). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BRACHYLOG_META_ITERATE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ brachylog_meta_iterate(GlobalVariables, 'first', P, Sub, ['integer':I|Input], Output) :- ( Input = [Arg] -> true ; Input = Arg ), brachylog_meta_iterate(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_iterate(GlobalVariables, 'last', P, Sub, Input, Output) :- reverse(Input, ['integer':I|T]), ( T = [Arg] -> true ; reverse(T, Arg) ), brachylog_meta_iterate(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_iterate(_, 'integer':0, _, _, Input, Input). brachylog_meta_iterate(GlobalVariables, 'default', P, Sub, Input, Output) :- I #>= 1, brachylog_meta_iterate(GlobalVariables, 'integer':I, P, Sub, Input, Output). brachylog_meta_iterate(GlobalVariables, 'integer':1, P, Sub, Input, Output) :- ( GlobalVariables = 'ignore', call(P, Sub, Input, Output) ; dif(GlobalVariables, 'ignore'), call(P, GlobalVariables, Sub, Input, Output) ). brachylog_meta_iterate(GlobalVariables, 'integer':I, P, Sub, Input, Output) :- I #> 1, ( GlobalVariables = 'ignore', call(P, Sub, Input, TOutput) ; dif(GlobalVariables, 'ignore'), call(P, GlobalVariables, Sub, Input, TOutput) ), J #= I - 1, brachylog_meta_iterate(GlobalVariables, 'integer':J, P, Sub, TOutput, Output). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BRACHYLOG_META_LEFTFOLD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ brachylog_meta_leftfold(GlobalVariables, 'first', P, Sub, ['integer':I|Input], Output) :- ( Input = [Arg] -> true ; Input = Arg ), brachylog_meta_leftfold(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_leftfold(GlobalVariables, 'last', P, Sub, Input, Output) :- reverse(Input, ['integer':I|T]), ( T = [Arg] -> true ; reverse(T, Arg) ), brachylog_meta_leftfold(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_leftfold(GlobalVariables, 'default', P, Sub, 'string':S, Output) :- brachylog_elements('default', 'string':S, E), brachylog_meta_leftfold(GlobalVariables, 'default', P, Sub, E, O), ( brachylog_concatenate('default', O, X), X = 'string':_ -> Output = X ; Output = O ). brachylog_meta_leftfold(GlobalVariables, 'default', P, Sub, 'integer':Input, Output) :- brachylog_elements('default', 'integer':Input, E), brachylog_meta_leftfold(GlobalVariables, 'default', P, Sub, E, O), ( brachylog_concatenate('default', O, X), X = 'integer':_ -> Output = X ; Output = O ). brachylog_meta_leftfold(_, 'default', _P, _Sub, [], []). brachylog_meta_leftfold(_, 'default', _P, _Sub, [X], [X]). brachylog_meta_leftfold(GlobalVariables, 'default', P, Sub, [H,I|T], Output) :- brachylog_meta_leftfold_(GlobalVariables, P, Sub, [I|T], H, Output). brachylog_meta_leftfold_(_, _P, _Sub, [], Output, Output). brachylog_meta_leftfold_(GlobalVariables, P, Sub, [H|T], A, Output) :- ( GlobalVariables = 'ignore', call(P, Sub, [A,H], E) ; dif(GlobalVariables, 'ignore'), call(P, GlobalVariables, Sub, [A,H], E) ), brachylog_meta_leftfold_(GlobalVariables, P, Sub, T, E, Output). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BRACHYLOG_META_MAP - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ brachylog_meta_map(GlobalVariables, 'first', P, Sub, ['integer':I|Input], Output) :- ( Input = [Arg] -> true ; Input = Arg ), brachylog_meta_map(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_map(GlobalVariables, 'last', P, Sub, Input, Output) :- reverse(Input, ['integer':I|T]), ( T = [Arg] -> true ; reverse(T, Arg) ), brachylog_meta_map(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_map(GlobalVariables, 'integer':0, P, Sub, Input, Output) :- ( GlobalVariables = 'ignore', call(P, Sub, Input, Output) ; dif(GlobalVariables, 'ignore'), call(P, GlobalVariables, Sub, Input, Output) ). brachylog_meta_map(GlobalVariables, 'default', P, Sub, Input, Output) :- brachylog_meta_map(GlobalVariables, 'integer':1, P, Sub, Input, Output). brachylog_meta_map(GlobalVariables, 'integer':I, P, Sub, 'string':S, Output) :- brachylog_elements('default', 'string':S, E), brachylog_meta_map(GlobalVariables, 'integer':I, P, Sub, E, O), ( brachylog_concatenate('default', O, X), X = 'string':_ -> Output = X ; Output = O ). brachylog_meta_map(GlobalVariables, 'integer':I, P, Sub, 'integer':Input, Output) :- brachylog_elements('default', 'integer':Input, E), brachylog_meta_map(GlobalVariables, 'integer':I, P, Sub, E, O), ( brachylog_concatenate('default', O, X), X = 'integer':_ -> Output = X ; Output = O ). brachylog_meta_map(GlobalVariables, 'integer':1, P, Sub, Input, Output) :- ( GlobalVariables = 'ignore', Pred =.. [P, Sub] ; dif(GlobalVariables, 'ignore'), Pred =.. [P, GlobalVariables, Sub] ), is_brachylog_list(Input), maplist(Pred, Input, Output). brachylog_meta_map(GlobalVariables, 'integer':I, P, Sub, Input, Output) :- I #> 1, J #= I - 1, is_brachylog_list(Input), maplist(brachylog_meta_map(GlobalVariables, 'integer':J, P, Sub), Input, Output). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BRACHYLOG_META_NONEXISTENCE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ brachylog_meta_nonexistence(GlobalVariables, 'first', P, Sub, [I|Input], Arg) :- ( Input = [Arg] -> true ; Input = Arg ), brachylog_meta_nonexistence(GlobalVariables, P, Sub, Arg, I). brachylog_meta_nonexistence(GlobalVariables, 'last', P, Sub, Input, Arg) :- reverse(Input, [I|T]), ( T = [Arg] -> true ; reverse(T, Arg) ), brachylog_meta_nonexistence(GlobalVariables, P, Sub, Arg, I). brachylog_meta_nonexistence(GlobalVariables, 'integer':I, P, Sub, Input, Input) :- dif(I, 'default'), brachylog_meta_nonexistence(GlobalVariables, P, Sub, Input, 'integer':I). brachylog_meta_nonexistence(GlobalVariables, 'default', P, Sub, Input, Output) :- brachylog_meta_nonexistence(GlobalVariables, P, Sub, Input, Output). brachylog_meta_nonexistence(GlobalVariables, P, Sub, Input, Output) :- brachylog_meta_map(GlobalVariables, 'default', P, Sub, Input, T), brachylog_zip('default', [T,[Output]], Z), brachylog_meta_map(GlobalVariables, 'default', brachylog_different, 'default', Z, _). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BRACHYLOG_META_ORDERBY - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ brachylog_meta_orderby(GlobalVariables, 'first', P, Sub, ['integer':I|Input], Output) :- ( Input = [Arg] -> true ; Input = Arg ), brachylog_meta_orderby(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_orderby(GlobalVariables, 'last', P, Sub, Input, Output) :- reverse(Input, ['integer':I|T]), ( T = [Arg] -> true ; reverse(T, Arg) ), brachylog_meta_orderby(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_orderby(GlobalVariables, 'default', P, Sub, Input, Output) :- brachylog_meta_orderby(GlobalVariables, 'integer':0, P, Sub, Input, Output). brachylog_meta_orderby(GlobalVariables, 'integer':0, P, Sub, Input, Output) :- ( is_brachylog_list(Input) -> FixedInput = Input ; brachylog_elements('default', Input, FixedInput) ), brachylog_meta_map(GlobalVariables, 'default', P, Sub, FixedInput, L), brachylog_zip('default', [L,Input], L2), brachylog_order(integer:0, L2, SL2), ( SL2 = [] -> Output = [] ; brachylog_zip('default', SL2, [_,Output]) ). brachylog_meta_orderby(GlobalVariables, 'integer':1, P, Sub, Input, Output) :- ( is_brachylog_list(Input) -> FixedInput = Input ; brachylog_elements('default', Input, FixedInput) ), brachylog_meta_map(GlobalVariables, 'default', P, Sub, FixedInput, L), brachylog_zip('default', [L,Input], L2), brachylog_order(integer:1, L2, SL2), ( SL2 = [] -> Output = [] ; brachylog_zip('default', SL2, [_,Output]) ). brachylog_meta_orderby(GlobalVariables, 'integer':2, P, Sub, Input, Output) :- ( is_brachylog_list(Input) -> FixedInput = Input ; brachylog_elements('default', Input, FixedInput) ), brachylog_meta_map(GlobalVariables, 'default', P, Sub, FixedInput, L), brachylog_order(integer:0, L, Output). brachylog_meta_orderby(GlobalVariables, 'integer':3, P, Sub, Input, Output) :- ( is_brachylog_list(Input) -> FixedInput = Input ; brachylog_elements('default', Input, FixedInput) ), brachylog_meta_map(GlobalVariables, 'default', P, Sub, FixedInput, L), brachylog_order(integer:1, L, Output). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BRACHYLOG_META_SELECT - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ brachylog_meta_select(GlobalVariables, 'first', P, Sub, ['integer':I|Input], Output) :- ( Input = [Arg] -> true ; Input = Arg ), brachylog_meta_select(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_select(GlobalVariables, 'last', P, Sub, Input, Output) :- reverse(Input, ['integer':I|T]), ( T = [Arg] -> true ; reverse(T, Arg) ), brachylog_meta_select(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_select(GlobalVariables, 'default', P, Sub, 'string':S, Output) :- brachylog_elements('default', 'string':S, E), brachylog_meta_select(GlobalVariables, 'default', P, Sub, E, O), ( brachylog_concatenate('default', O, X), X = 'string':_ -> Output = X ; Output = O ). brachylog_meta_select(GlobalVariables, 'default', P, Sub, 'integer':S, Output) :- brachylog_elements('default', 'integer':S, E), brachylog_meta_select(GlobalVariables, 'default', P, Sub, E, O), ( brachylog_concatenate('default', O, X), X = 'integer':_ -> Output = X ; Output = O ). brachylog_meta_select(_, 'default', _, _, [], []). brachylog_meta_select(GlobalVariables, 'default', P, Sub, [H|T], Output) :- ( ( GlobalVariables = 'ignore', call(P, Sub, H, H2) ; dif(GlobalVariables, 'ignore'), call(P, GlobalVariables, Sub, H, H2) ) *-> Output = [H2|T2] ; Output = T2 ), brachylog_meta_select(GlobalVariables, 'default', P, Sub, T, T2). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BRACHYLOG_META_TAIL - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ brachylog_meta_tail(GlobalVariables, 'first', P, Sub, ['integer':I|Input], Output) :- ( Input = [Arg] -> true ; Input = Arg ), brachylog_meta_tail(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_tail(GlobalVariables, 'last', P, Sub, Input, Output) :- reverse(Input, ['integer':I|T]), ( T = [Arg] -> true ; reverse(T, Arg) ), brachylog_meta_tail(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_tail(GlobalVariables, 'default', P, Sub, Input, Output) :- brachylog_meta_tail(GlobalVariables, 'integer':1, P, Sub, Input, Output). brachylog_meta_tail(_, 'integer':0, _, _, Input, Input). brachylog_meta_tail(GlobalVariables, 'integer':I, P, Sub, Input, Output) :- I #> 0, brachylog_tail('integer':I, Input, Tails), brachylog_knife('integer':I, Input, Heads), brachylog_meta_map(GlobalVariables, 'default', P, Sub, Tails, NewTails), brachylog_concatenate('default', [Heads,NewTails], Output). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BRACHYLOG_META_UNIQUE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ brachylog_meta_unique(GlobalVariables, 'first', P, Sub, ['integer':I|Input], Output) :- ( Input = [Arg] -> true ; Input = Arg ), brachylog_meta_unique(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_unique(GlobalVariables, 'last', P, Sub, Input, Output) :- reverse(Input, ['integer':I|T]), ( T = [Arg] -> true ; reverse(T, Arg) ), brachylog_meta_unique(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_unique(GlobalVariables, 'default', P, Sub, Input, Output) :- brachylog_meta_unique_(GlobalVariables, 1, -1, P, Sub, Input, [], Output). brachylog_meta_unique(_, 'integer':0, _, _, _, []). brachylog_meta_unique(GlobalVariables, 'integer':I, P, Sub, Input, Output) :- brachylog_meta_unique_(GlobalVariables, 1, I, P, Sub, Input, [], Output). brachylog_meta_unique_(_, _, 0, _, _, _, ROutput, Output) :- reverse(ROutput, Output). brachylog_meta_unique_(GlobalVariables, Nth, J, P, Sub, Input, A, Output) :- J #\= 0, ( call_nth( ( GlobalVariables = 'ignore', call(P, Sub, Input, X) ; dif(GlobalVariables, 'ignore'), call(P, GlobalVariables, Sub, Input, X) ), Nth) -> ( \+ member(X, A) -> M #= Nth + 1, K #= J - 1, brachylog_meta_unique_(GlobalVariables, M, K, P, Sub, Input, [X|A], Output) ; M #= Nth + 1, brachylog_meta_unique_(GlobalVariables, M, J, P, Sub, Input, A, Output) ) ; reverse(A, Output) ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BRACHYLOG_META_VERIFY - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ brachylog_meta_verify(GlobalVariables, 'first', P, Sub, [I|Input], Arg) :- ( Input = [Arg] -> true ; Input = Arg ), brachylog_meta_verify(GlobalVariables, P, Sub, Arg, I). brachylog_meta_verify(GlobalVariables, 'last', P, Sub, Input, Arg) :- reverse(Input, [I|T]), ( T = [Arg] -> true ; reverse(T, Arg) ), brachylog_meta_verify(GlobalVariables, P, Sub, Arg, I). brachylog_meta_verify(GlobalVariables, 'integer':I, P, Sub, Input, Input) :- dif(I, 'default'), brachylog_meta_verify(GlobalVariables, P, Sub, Input, 'integer':I). brachylog_meta_verify(GlobalVariables, 'default', P, Sub, Input, Output) :- brachylog_meta_verify(GlobalVariables, P, Sub, Input, Output). brachylog_meta_verify(GlobalVariables, P, Sub, Input, Output) :- brachylog_length('default', Input, L), brachylog_length('default', T, L), brachylog_equal('default', T, _), brachylog_head('default', T, Output), brachylog_meta_map(GlobalVariables, 'default', P, Sub, Input, T). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BRACHYLOG_META_ZIP - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ brachylog_meta_zip(GlobalVariables, 'first', P, Sub, ['integer':I|Input], Output) :- ( Input = [Arg] -> true ; Input = Arg ), brachylog_meta_zip(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_zip(GlobalVariables, 'last', P, Sub, Input, Output) :- reverse(Input, ['integer':I|T]), ( T = [Arg] -> true ; reverse(T, Arg) ), brachylog_meta_zip(GlobalVariables, 'integer':I, P, Sub, Arg, Output). brachylog_meta_zip(GlobalVariables, 'default', P, Sub, Arg, Output) :- brachylog_meta_map(GlobalVariables, 'default', P, Sub, Arg, O), brachylog_zip('default', [Arg,O], Output). brachylog_meta_zip(GlobalVariables, 'integer':0, P, Sub, Arg, Output) :- brachylog_meta_find(GlobalVariables, 'default', P, Sub, Arg, O), brachylog_zip('default', [Arg,O], Output). brachylog_meta_zip(GlobalVariables, 'integer':1, P, Sub, Arg, Output) :- brachylog_meta_map(GlobalVariables, 'default', P, Sub, Arg, O), brachylog_zip('default', [O,Arg], Output). brachylog_meta_zip(GlobalVariables, 'integer':2, P, Sub, Arg, Output) :- brachylog_meta_find(GlobalVariables, 'default', P, Sub, Arg, O), brachylog_zip('default', [O,Arg], Output).
JCumin/Brachylog
src/metapredicates.pl
Perl
mit
29,501
# Copyrights 2001-2008 by Mark Overmeer. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 1.04. use strict; use warnings; package Mail::Message::Convert::HtmlFormatPS; use vars '$VERSION'; $VERSION = '2.082'; use base 'Mail::Message::Convert'; use Mail::Message::Body::String; use HTML::TreeBuilder; use HTML::FormatText; sub init($) { my ($self, $args) = @_; my @formopts = map { ($_ => delete $args->{$_} ) } grep m/^[A-Z]/, keys %$args; $self->SUPER::init($args); $self->{MMCH_formatter} = HTML::FormatPS->new(@formopts); $self; } #------------------------------------------ sub format($) { my ($self, $body) = @_; my $dec = $body->encode(transfer_encoding => 'none'); my $tree = HTML::TreeBuilder->new_from_file($dec->file); (ref $body)->new ( based_on => $body , mime_type => 'application/postscript' , data => [ $self->{MMCH_formatter}->format($tree) ] ); } #------------------------------------------ 1;
carlgao/lenga
images/lenny64-peon/usr/share/perl5/Mail/Message/Convert/HtmlFormatPS.pm
Perl
mit
1,101
################################################## package Log::Log4perl::Appender::Socket; ################################################## our @ISA = qw(Log::Log4perl::Appender); use warnings; use strict; use IO::Socket::INET; ################################################## sub new { ################################################## my($class, @options) = @_; my $self = { name => "unknown name", silent_recovery => 0, PeerAddr => "localhost", Proto => 'tcp', Timeout => 5, @options, }; bless $self, $class; unless ($self->{defer_connection}){ unless($self->connect(@options)) { if($self->{silent_recovery}) { warn "Connect to $self->{PeerAddr}:$self->{PeerPort} failed: $!"; return $self; } die "Connect to $self->{PeerAddr}:$self->{PeerPort} failed: $!"; } $self->{socket}->autoflush(1); #autoflush has been the default behavior since 1997 } return $self; } ################################################## sub connect { ################################################## my($self, @options) = @_; $self->{socket} = IO::Socket::INET->new(@options); return $self->{socket}; } ################################################## sub log { ################################################## my($self, %params) = @_; { # If we were never able to establish # a connection, try to establish one # here. If it fails, return. if(($self->{silent_recovery} or $self->{defer_connection}) and !defined $self->{socket}) { if(! $self->connect(%$self)) { return undef; } } # Try to send the message across eval { $self->{socket}->send($params{message}); }; if($@) { warn "Send to " . ref($self) . " failed ($@), retrying once..."; if($self->connect(%$self)) { redo; } if($self->{silent_recovery}) { return undef; } warn "Reconnect to $self->{PeerAddr}:$self->{PeerPort} " . "failed: $!"; return undef; } }; return 1; } ################################################## sub DESTROY { ################################################## my($self) = @_; undef $self->{socket}; } 1; __END__ =head1 NAME Log::Log4perl::Appender::Socket - Log to a socket =head1 SYNOPSIS use Log::Log4perl::Appender::Socket; my $appender = Log::Log4perl::Appender::Socket->new( PeerAddr => "server.foo.com", PeerPort => 1234, ); $appender->log(message => "Log me\n"); =head1 DESCRIPTION This is a simple appender for writing to a socket. It relies on L<IO::Socket::INET> and offers all parameters this module offers. Upon destruction of the object, pending messages will be flushed and the socket will be closed. If the appender cannot contact the server during the initialization phase (while running the constructor C<new>), it will C<die()>. If the appender fails to log a message because the socket's C<send()> method fails (most likely because the server went down), it will try to reconnect once. If it succeeds, the message will be sent. If the reconnect fails, a warning is sent to STDERR and the C<log()> method returns, discarding the message. If the option C<silent_recovery> is given to the constructor and set to a true value, the behaviour is different: If the socket connection can't be established at initialization time, a single warning is issued. Every log attempt will then try to establish the connection and discard the message silently if it fails. Connecting at initialization time may not be the best option when running under Apache1 Apache2/prefork, because the parent process creates the socket and the connections are shared among the forked children--all the children writing to the same socket could intermingle messages. So instead of that, you can use C<defer_connection> which will put off making the connection until the first log message is sent. =head1 EXAMPLE Write a server quickly using the IO::Socket::INET module: use IO::Socket::INET; my $sock = IO::Socket::INET->new( Listen => 5, LocalAddr => 'localhost', LocalPort => 12345, Proto => 'tcp'); while(my $client = $sock->accept()) { print "Client connected\n"; while(<$client>) { print "$_\n"; } } Start it and then run the following script as a client: use Log::Log4perl qw(:easy); my $conf = q{ log4perl.category = WARN, Socket log4perl.appender.Socket = Log::Log4perl::Appender::Socket log4perl.appender.Socket.PeerAddr = localhost log4perl.appender.Socket.PeerPort = 12345 log4perl.appender.Socket.layout = SimpleLayout }; Log::Log4perl->init(\$conf); sleep(2); for(1..10) { ERROR("Quack!"); sleep(5); } =head1 AUTHOR Mike Schilli <log4perl@perlmeister.com>, 2003 =cut
carlgao/lenga
images/lenny64-peon/usr/share/perl5/Log/Log4perl/Appender/Socket.pm
Perl
mit
5,267
#Copyright (C)2001-2010 Altera Corporation #Any megafunction design, and related net list (encrypted or decrypted), #support information, device programming or simulation file, and any other #associated documentation or information provided by Altera or a partner #under Altera's Megafunction Partnership Program may be used only to #program PLD devices (but not masked PLD devices) from Altera. Any other #use of such megafunction design, net list, support information, device #programming or simulation file, or any other related documentation or #information is prohibited for any other purpose, including, but not #limited to modification, reverse engineering, de-compiling, or use with #any other silicon devices, unless such use is explicitly licensed under #a separate agreement with Altera or a megafunction partner. Title to #the intellectual property, including patents, copyrights, trademarks, #trade secrets, or maskworks, embodied in any such megafunction design, #net list, support information, device programming or simulation file, or #any other related documentation or information provided by Altera or a #megafunction partner, remains with Altera, the megafunction partner, or #their respective licensors. No other licenses, including any licenses #needed under any third party's intellectual property, are provided herein. #Copying or modifying any file, or portion thereof, to which this notice #is attached violates this copyright. use europa_all; use strict; my $Read_Wait_States = 1; my $Write_Wait_States = 1; my $Address_Width = 9; # 2KBytes = 11 bits, 32 bits --> -2. my $Data_Width = 32; my $default_databits = "8"; my $default_targetclock = "20"; my $default_clockunits = "MHz"; my $default_numslaves = "1"; my $default_ismaster = "1"; my $default_clockpolarity = "0"; my $default_clockphase = "0"; my $default_lsbfirst = "0"; my $default_extradelay = "0"; my $default_targetssdelay = "100"; my $default_delayunits = "us"; my $default_clockmult; ($default_clockmult = $default_clockunits) =~ s/Hz//; $default_clockmult = unit_prefix_to_num($default_clockmult); my $default_delaymult; ($default_delaymult = $default_delayunits) =~ s/s//; $default_delaymult = unit_prefix_to_num($default_delaymult); my $g_slave_name = 'epcs_control_port'; sub get_slave_name { return $g_slave_name; } sub get_code_size { my $project = shift; my $device_family = uc($project->system_ptf()->{WIZARD_SCRIPT_ARGUMENTS}->{device_family}); if( ($device_family eq "STRATIXII") || ($device_family eq "STRATIXIIGX") || ($device_family eq "STRATIXIIGXLITE") || ($device_family eq "STRATIXIII") || ($device_family eq "STRATIXIV") || ($device_family eq "STRATIXV") || ($device_family eq "ARRIAII") || ($device_family eq "ARRIAIIGZ") || ($device_family eq "ARRIAV") || ($device_family eq "ARRIAVGZ") || ($device_family eq "STRATIXIIGXLITE") || ($device_family eq "CYCLONEIII")|| ($device_family eq "TARPON") || ($device_family eq "CYCLONEIVE") || ($device_family eq "STINGRAY") || ($device_family eq "CYCLONEV")) { return 0x400; } else { return 0x200; } } sub add_make_target_ptf_assignments { my $project = shift; my $name = $project->_target_module_name(); my $wsa = $project->system_ptf()->{"MODULE $name"}->{WIZARD_SCRIPT_ARGUMENTS}; my $sbi = $project->system_ptf()->{"MODULE $name"}->{SYSTEM_BUILDER_INFO}; my $slave_sbi = $project->SBI("$name/$g_slave_name"); my $slave_wsa = $project->system_ptf()->{"MODULE $name"}->{"SLAVE $g_slave_name"}-> {WIZARD_SCRIPT_ARGUMENTS}; my $refdes = $slave_wsa->{epcs_flash_refdes}; my @targets = qw(flashfiles dat programflash); } sub validate_epcs_parameters { my ($Options, $system_WSA) = @_; validate_parameter ({ hash => $system_WSA, name => "clock_freq", type => "integer", }); validate_parameter ({ hash => $Options, name => "ismaster", type => "boolean", default => $default_ismaster, }); validate_parameter ({ hash => $Options, name => "databits", type => "integer", range => [1,16], default => $default_databits, }); validate_parameter ({ hash => $Options, name => "targetclock", type => "string", default => $default_targetclock, }); validate_parameter ({ hash => $Options, name => "numslaves", type => "integer", range => [1, 16], default => $default_numslaves, }); validate_parameter ({ hash => $Options, name => "clockpolarity", type => "boolean", default => $default_clockpolarity, }); validate_parameter ({ hash => $Options, name => "clockphase", type => "boolean", default => $default_clockphase, }); validate_parameter ({ hash => $Options, name => "lsbfirst", type => "boolean", default => $default_lsbfirst, }); validate_parameter ({ hash => $Options, name => "extradelay", type => "boolean", default => $default_extradelay, }); validate_parameter ({ hash => $Options, name => "targetssdelay", type => "string", default => $default_targetssdelay, }); validate_parameter ({ hash => $Options, name => "delayunit", type => "string", default => $default_delayunits, allowed => ["s", "ms", "us", "ns"], }); validate_parameter ({ hash => $Options, name => "clockunit", type => "string", allowed => ["Hz", "kHz", "MHz", ], default => $default_clockunits, }); } sub make_epcs { if (!@_) { return make_class_ptf(); } die "Don't make an EPCS this way!\n"; } my $global_magic_comment_string = <<EOP ; EOP sub do_create_class_ptf { return 1; } sub make_class_ptf { if (!do_create_class_ptf()) { print STDERR "Not generating class.ptf: user has overridden.\n\n"; return; } open FILE, ">class.ptf" or ribbit("Can't open 'class.ptf'\n"); print FILE qq[$global_magic_comment_string CLASS altera_avalon_epcs_flash_controller { SDK_GENERATION { SDK_FILES 0 { cpu_architecture = "always"; short_type = "epcs"; c_structure_type = "np_epcs *"; c_header_file = "sdk/epcs_struct.h"; sdk_files_dir = "sdk"; } SDK_FILES 1 { cpu_architecture = "always"; toolchain = "gnu"; asm_header_file = "sdk/epcs_struct.s"; } } ASSOCIATED_FILES { Add_Program = "default"; Edit_Program = "default"; Generator_Program = "em_epcs.pl"; Bind_Program = "bind"; } MODULE_DEFAULTS { class = "altera_avalon_epcs_flash_controller"; class_version = "2.1"; SLAVE epcs_control_port { SYSTEM_BUILDER_INFO { Bus_Type = "avalon"; Is_Nonvolatile_Storage = "1"; Is_Printable_Device = "0"; Address_Alignment = "dynamic"; Is_Memory_Device = "1"; Address_Width = "9"; Data_Width = "32"; Has_IRQ = "1"; Read_Wait_States = "1"; Write_Wait_States = "1"; } WIZARD_SCRIPT_ARGUMENTS { class = "altera_avalon_epcs_flash_controller"; } } SYSTEM_BUILDER_INFO { Is_Enabled= "1"; Instantiate_In_System_Module = "1"; Required_Device_Family = "STRATIX,CYCLONE,CYCLONEII,CYCLONEIII,STRATIXIII,STRATIXII,STRATIXIIGX,ARRIAGX,STRATIXIIGXLITE,STRATIXIV,STRATIXV,ARRIAII,ARRIAIIGZ,ARRIAV,ARRIAVGZ,TARPON,STINGRAY,CYCLONEIVE,CYCLONEV"; Fixed_Module_Name = "epcs_controller"; Top_Level_Ports_Are_Enumerated = "1"; } WIZARD_SCRIPT_ARGUMENTS { databits = "8"; targetclock = "20"; clockunits = "MHz"; clockmult = "1000000"; numslaves = "1"; ismaster = "1"; clockpolarity = "0"; clockphase = "0"; lsbfirst = "0"; extradelay = "0"; targetssdelay = "100"; delayunits = "us"; delaymult = "1.e-06"; prefix = "epcs_"; register_offset = ""; } } USER_INTERFACE { USER_LABELS { name="EPCS Serial Flash Controller"; technology="Memory,EP1C20 Nios Development Board Cyclone Edition"; alias="epcs"; } WIZARD_UI default { title = "EPCS Serial Flash Controller - {{ \$MOD }}"; CONTEXT { SWSA = "SLAVE epcs_control_port/WIZARD_SCRIPT_ARGUMENTS"; WSA = "WIZARD_SCRIPT_ARGUMENTS"; SBI = "SLAVE epcs_control_port/SYSTEM_BUILDER_INFO"; MODULE_SBI = "SYSTEM_BUILDER_INFO"; SPWA = "SLAVE epcs_control_port/PORT_WIRING/PORT address"; SPWD = "SLAVE epcs_control_port/PORT_WIRING/PORT data"; } error = "{{ if (device_info('has_EPCS') == 0) {'EPCS-capable device required'}; }}"; \$\$non_asmi_support="{{((\$SYS/device_family_id == 'CYCLONEIII') || (\$SYS/device_family_id == 'TARPON') || (\$SYS/device_family_id == 'STINGRAY') || (\$SYS/device_family_id == 'CYCLONEIVE') || (\$SYS/device_family_id == 'CYCLONEV') || (\$SYS/hardcopy_compatible == '1'))}}"; \$\$no_legacy_validation="{{\$WSA/ignore_legacy_check}}"; \$\$sopc_asmi_setting="{{\$WSA/use_asmi_atom}}"; \$\$legacy_asmi_setting = "{{ if (\$\$non_asmi_support) '0'; else '1'; }}"; \$WSA/use_asmi_atom = "{{ if (\$\$no_legacy_validation) \$\$sopc_asmi_setting; else \$\$legacy_asmi_setting; }}"; \$\$epcs_new_refdes = "{{ if (\$SWSA/flash_reference_designator == '') '--none--'; else \$SWSA/flash_reference_designator; }}"; \$\$add_code = "{{ if (\$\$add) 1; else 0; }}"; \$\$edit_code = "{{ if (\$\$edit) 1; else 0; }}"; \$\$cfi_utilcomponentclass = "altera_avalon_cfi_flash"; \$\$no_board_is_selected = 0; \$\$epcs_instances = "{{ sopc_slave_list('WIZARD_SCRIPT_ARGUMENTS/class=altera_avalon_epcs_flash_controller'); }}"; \$\$cfi_component_dir = "{{ sopc_get_component_dir(\$\$cfi_utilcomponentclass); }}"; code = "{{ \$\$board_info = exec_and_wait( \$\$cfi_component_dir+'/cfi_flash.pl', 'get_board_info', \$\$system_directory+'/'+\$SYSTEM+'.ptf', \$\$/target_module_name, \$\$epcs_instances, 'epcs_control_port', \$\$epcs_new_refdes, \$\$add_code, \$\$edit_code, \$SYSTEM/WIZARD_SCRIPT_ARGUMENTS/board_class, \$BUS/BOARD_INFO/altera_avalon_epcs_flash_controller/reference_designators ); \$\$extra_info = exec_and_wait( \$\$cfi_component_dir+'/cfi_flash.pl', 'get_extra_info', \$\$system_directory+'/'+\$SYSTEM+'.ptf', \$\$/target_module_name, \$\$epcs_instances, 'epcs_control_port', \$\$epcs_new_refdes, \$\$add_code, \$\$edit_code, \$SYSTEM/WIZARD_SCRIPT_ARGUMENTS/board_class, \$BUS/BOARD_INFO/altera_avalon_epcs_flash_controller/reference_designators ); if (\$\$board_info == 'no_board') { \$\$no_board_is_selected = 1; \$\$error_message = ''; \$\$message_message = 'No Matching Ref Des in System Board Target'; \$\$warning_message = ''; \$\$enabled_combo = 1; \$\$editable_combo = 1; } if (\$\$board_info == 'error') { \$\$error_message = \$\$extra_info; \$\$warning_message = ''; \$\$message_message = ''; \$\$enabled_combo = 1; \$\$editable_combo = 1; } if (\$\$board_info == 'warning') { \$\$warning_message = \$\$extra_info; \$\$error_message = ''; \$\$message_message = ''; \$\$enabled_combo = 1; \$\$editable_combo = 1; } if (\$\$board_info == '1_ref_des') { \$\$message_message = ''; \$\$error_message = ''; \$\$warning_message = ''; \$\$enabled_combo = 0; \$\$editable_combo = 0; } if (\$\$board_info == 'some_ref_des') { \$\$error_message = ''; \$\$warning_message = ''; \$\$message_message = ''; \$\$enabled_combo = 1; \$\$editable_combo = 0; } }}"; ACTION initialize { code = "{{ if (\$\$add) { if (\$\$board_info == 'some_ref_des') { \$SWSA/flash_reference_designator = \$\$extra_info; \$\$epcs_new_refdes = \$\$extra_info; } if (\$\$board_info == '1_ref_des') { \$SWSA/flash_reference_designator = \$\$extra_info; \$\$epcs_new_refdes = \$\$extra_info; } } }}"; } PAGES main { PAGE 1 { title = "Attributes"; GROUP { title = "Board Info"; COMBO refdes { title = "Reference Designator (chip label): "; key = "R"; values = "{{ \$BUS/BOARD_INFO/altera_avalon_epcs_flash_controller/reference_designators }}"; editable = "0"; enable = "{{ \$\$enabled_combo; }}"; message = "{{ \$\$message_message; }}"; DATA { \$SWSA/flash_reference_designator = "\$"; \$\$epcs_new_refdes = "\$"; } } } } } } WIZARD_UI bind { visible = "0"; CONTEXT { WSA = "WIZARD_SCRIPT_ARGUMENTS"; } \$\$non_asmi_support="{{((\$SYS/device_family_id == 'CYCLONEIII') || (\$SYS/device_family_id == 'STINGRAY') || (\$SYS/device_family_id == 'CYCLONEIVE') || (\$SYS/device_family_id == 'CYCLONEV') || (\$SYS/hardcopy_compatible == '1'))}}"; \$\$no_legacy_validation="{{\$WSA/ignore_legacy_check}}"; \$\$sopc_asmi_setting="{{\$WSA/use_asmi_atom}}"; \$\$legacy_asmi_setting = "{{ if (\$\$non_asmi_support) '0'; else '1'; }}"; \$WSA/use_asmi_atom = "{{ if (\$\$no_legacy_validation) \$\$sopc_asmi_setting; else \$\$legacy_asmi_setting; }}"; } LINKS { LINK help { title="Data Sheet"; url="http://www.altera.com/literature/hb/nios2/n2cpu_nii51012.pdf"; } LINK Cyclone_Data_Sheet { title="Manual for Nios 1c20 Cyclone Board"; url="http://www.altera.com/literature/manual/mnl_nios2_board_cyclone_1c20.pdf"; } LINK Cyclone_Schematics { title="Schematics for Nios 1c20 Cyclone Board"; url="nios_cyclone_1c20/nios_1c20_board_schematic.pdf"; } } } } ]; close FILE; } return 1;
UdayanSinha/Code_Blocks
Nios-2/Nios/practica4/ip/bemicro_max10_serial_flash_controller/em_epcs.pm
Perl
mit
16,275
package Fatal; use 5.008; # 5.8.x needed for autodie use Carp; use strict; use warnings; use Tie::RefHash; # To cache subroutine refs use Config; use constant PERL510 => ( $] >= 5.010 ); use constant LEXICAL_TAG => q{:lexical}; use constant VOID_TAG => q{:void}; use constant INSIST_TAG => q{!}; use constant ERROR_NOARGS => 'Cannot use lexical %s with no arguments'; use constant ERROR_VOID_LEX => VOID_TAG.' cannot be used with lexical scope'; use constant ERROR_LEX_FIRST => LEXICAL_TAG.' must be used as first argument'; use constant ERROR_NO_LEX => "no %s can only start with ".LEXICAL_TAG; use constant ERROR_BADNAME => "Bad subroutine name for %s: %s"; use constant ERROR_NOTSUB => "%s is not a Perl subroutine"; use constant ERROR_NOT_BUILT => "%s is neither a builtin, nor a Perl subroutine"; use constant ERROR_NOHINTS => "No user hints defined for %s"; use constant ERROR_CANT_OVERRIDE => "Cannot make the non-overridable builtin %s fatal"; use constant ERROR_NO_IPC_SYS_SIMPLE => "IPC::System::Simple required for Fatalised/autodying system()"; use constant ERROR_IPC_SYS_SIMPLE_OLD => "IPC::System::Simple version %f required for Fatalised/autodying system(). We only have version %f"; use constant ERROR_AUTODIE_CONFLICT => q{"no autodie '%s'" is not allowed while "use Fatal '%s'" is in effect}; use constant ERROR_FATAL_CONFLICT => q{"use Fatal '%s'" is not allowed while "no autodie '%s'" is in effect}; use constant ERROR_58_HINTS => q{Non-subroutine %s hints for %s are not supported under Perl 5.8.x}; # Older versions of IPC::System::Simple don't support all the # features we need. use constant MIN_IPC_SYS_SIMPLE_VER => 0.12; # All the Fatal/autodie modules share the same version number. our $VERSION = '2.12'; our $Debug ||= 0; # EWOULDBLOCK values for systems that don't supply their own. # Even though this is defined with our, that's to help our # test code. Please don't rely upon this variable existing in # the future. our %_EWOULDBLOCK = ( MSWin32 => 33, ); # the linux parisc port has separate EAGAIN and EWOULDBLOCK, # and the kernel returns EAGAIN my $try_EAGAIN = ($^O eq 'linux' and $Config{archname} =~ /hppa|parisc/) ? 1 : 0; # We have some tags that can be passed in for use with import. # These are all assumed to be CORE:: my %TAGS = ( ':io' => [qw(:dbm :file :filesys :ipc :socket read seek sysread syswrite sysseek )], ':dbm' => [qw(dbmopen dbmclose)], ':file' => [qw(open close flock sysopen fcntl fileno binmode ioctl truncate chmod)], ':filesys' => [qw(opendir closedir chdir link unlink rename mkdir symlink rmdir readlink umask)], ':ipc' => [qw(:msg :semaphore :shm pipe)], ':msg' => [qw(msgctl msgget msgrcv msgsnd)], ':threads' => [qw(fork)], ':semaphore'=>[qw(semctl semget semop)], ':shm' => [qw(shmctl shmget shmread)], ':system' => [qw(system exec)], # Can we use qw(getpeername getsockname)? What do they do on failure? # TODO - Can socket return false? ':socket' => [qw(accept bind connect getsockopt listen recv send setsockopt shutdown socketpair)], # Our defaults don't include system(), because it depends upon # an optional module, and it breaks the exotic form. # # This *may* change in the future. I'd love IPC::System::Simple # to be a dependency rather than a recommendation, and hence for # system() to be autodying by default. ':default' => [qw(:io :threads)], # Everything in v2.07 and brefore. This was :default less chmod. ':v207' => [qw(:threads :dbm :filesys :ipc :socket read seek sysread syswrite sysseek open close flock sysopen fcntl fileno binmode ioctl truncate)], # Version specific tags. These allow someone to specify # use autodie qw(:1.994) and know exactly what they'll get. ':1.994' => [qw(:v207)], ':1.995' => [qw(:v207)], ':1.996' => [qw(:v207)], ':1.997' => [qw(:v207)], ':1.998' => [qw(:v207)], ':1.999' => [qw(:v207)], ':1.999_01' => [qw(:v207)], ':2.00' => [qw(:v207)], ':2.01' => [qw(:v207)], ':2.02' => [qw(:v207)], ':2.03' => [qw(:v207)], ':2.04' => [qw(:v207)], ':2.05' => [qw(:v207)], ':2.06' => [qw(:v207)], ':2.06_01' => [qw(:v207)], ':2.07' => [qw(:v207)], # Last release without chmod ':2.08' => [qw(:default)], ':2.09' => [qw(:default)], ':2.10' => [qw(:default)], ':2.11' => [qw(:default)], ':2.12' => [qw(:default)], ); # chmod was only introduced in 2.07 $TAGS{':all'} = [ keys %TAGS ]; # This hash contains subroutines for which we should # subroutine() // die() rather than subroutine() || die() my %Use_defined_or; # CORE::open returns undef on failure. It can legitimately return # 0 on success, eg: open(my $fh, '-|') || exec(...); @Use_defined_or{qw( CORE::fork CORE::recv CORE::send CORE::open CORE::fileno CORE::read CORE::readlink CORE::sysread CORE::syswrite CORE::sysseek CORE::umask )} = (); # A snippet of code to apply the open pragma to a handle # Optional actions to take on the return value before returning it. my %Retval_action = ( "CORE::open" => q{ # apply the open pragma from our caller if( defined $retval ) { # Get the caller's hint hash my $hints = (caller 0)[10]; # Decide if we're reading or writing and apply the appropriate encoding # These keys are undocumented. # Match what PerlIO_context_layers() does. Read gets the read layer, # everything else gets the write layer. my $encoding = $_[1] =~ /^\+?>/ ? $hints->{"open>"} : $hints->{"open<"}; # Apply the encoding, if any. if( $encoding ) { binmode $_[0], $encoding; } } }, "CORE::sysopen" => q{ # apply the open pragma from our caller if( defined $retval ) { # Get the caller's hint hash my $hints = (caller 0)[10]; require Fcntl; # Decide if we're reading or writing and apply the appropriate encoding. # Match what PerlIO_context_layers() does. Read gets the read layer, # everything else gets the write layer. my $open_read_only = !($_[2] ^ Fcntl::O_RDONLY()); my $encoding = $open_read_only ? $hints->{"open<"} : $hints->{"open>"}; # Apply the encoding, if any. if( $encoding ) { binmode $_[0], $encoding; } } }, ); # Cached_fatalised_sub caches the various versions of our # fatalised subs as they're produced. This means we don't # have to build our own replacement of CORE::open and friends # for every single package that wants to use them. my %Cached_fatalised_sub = (); # Every time we're called with package scope, we record the subroutine # (including package or CORE::) in %Package_Fatal. This allows us # to detect illegal combinations of autodie and Fatal, and makes sure # we don't accidently make a Fatal function autodying (which isn't # very useful). my %Package_Fatal = (); # The first time we're called with a user-sub, we cache it here. # In the case of a "no autodie ..." we put back the cached copy. my %Original_user_sub = (); # Is_fatalised_sub simply records a big map of fatalised subroutine # refs. It means we can avoid repeating work, or fatalising something # we've already processed. my %Is_fatalised_sub = (); tie %Is_fatalised_sub, 'Tie::RefHash'; # We use our package in a few hash-keys. Having it in a scalar is # convenient. The "guard $PACKAGE" string is used as a key when # setting up lexical guards. my $PACKAGE = __PACKAGE__; my $PACKAGE_GUARD = "guard $PACKAGE"; my $NO_PACKAGE = "no $PACKAGE"; # Used to detect 'no autodie' # Here's where all the magic happens when someone write 'use Fatal' # or 'use autodie'. sub import { my $class = shift(@_); my @original_args = @_; my $void = 0; my $lexical = 0; my $insist_hints = 0; my ($pkg, $filename) = caller(); @_ or return; # 'use Fatal' is a no-op. # If we see the :lexical flag, then _all_ arguments are # changed lexically if ($_[0] eq LEXICAL_TAG) { $lexical = 1; shift @_; # If we see no arguments and :lexical, we assume they # wanted ':default'. if (@_ == 0) { push(@_, ':default'); } # Don't allow :lexical with :void, it's needlessly confusing. if ( grep { $_ eq VOID_TAG } @_ ) { croak(ERROR_VOID_LEX); } } if ( grep { $_ eq LEXICAL_TAG } @_ ) { # If we see the lexical tag as the non-first argument, complain. croak(ERROR_LEX_FIRST); } my @fatalise_these = @_; # Thiese subs will get unloaded at the end of lexical scope. my %unload_later; # This hash helps us track if we've alredy done work. my %done_this; # NB: we're using while/shift rather than foreach, since # we'll be modifying the array as we walk through it. while (my $func = shift @fatalise_these) { if ($func eq VOID_TAG) { # When we see :void, set the void flag. $void = 1; } elsif ($func eq INSIST_TAG) { $insist_hints = 1; } elsif (exists $TAGS{$func}) { # When it's a tag, expand it. push(@fatalise_these, @{ $TAGS{$func} }); } else { # Otherwise, fatalise it. # Check to see if there's an insist flag at the front. # If so, remove it, and insist we have hints for this sub. my $insist_this; if ($func =~ s/^!//) { $insist_this = 1; } # TODO: Even if we've already fatalised, we should # check we've done it with hints (if $insist_hints). # If we've already made something fatal this call, # then don't do it twice. next if $done_this{$func}; # We're going to make a subroutine fatalistic. # However if we're being invoked with 'use Fatal qw(x)' # and we've already been called with 'no autodie qw(x)' # in the same scope, we consider this to be an error. # Mixing Fatal and autodie effects was considered to be # needlessly confusing on p5p. my $sub = $func; $sub = "${pkg}::$sub" unless $sub =~ /::/; # If we're being called as Fatal, and we've previously # had a 'no X' in scope for the subroutine, then complain # bitterly. if (! $lexical and $^H{$NO_PACKAGE}{$sub}) { croak(sprintf(ERROR_FATAL_CONFLICT, $func, $func)); } # We're not being used in a confusing way, so make # the sub fatal. Note that _make_fatal returns the # old (original) version of the sub, or undef for # built-ins. my $sub_ref = $class->_make_fatal( $func, $pkg, $void, $lexical, $filename, ( $insist_this || $insist_hints ) ); $done_this{$func}++; $Original_user_sub{$sub} ||= $sub_ref; # If we're making lexical changes, we need to arrange # for them to be cleaned at the end of our scope, so # record them here. $unload_later{$func} = $sub_ref if $lexical; } } if ($lexical) { # Dark magic to have autodie work under 5.8 # Copied from namespace::clean, that copied it from # autobox, that found it on an ancient scroll written # in blood. # This magic bit causes %^H to be lexically scoped. $^H |= 0x020000; # Our package guard gets invoked when we leave our lexical # scope. push(@ { $^H{$PACKAGE_GUARD} }, autodie::Scope::Guard->new(sub { $class->_install_subs($pkg, \%unload_later); })); # To allow others to determine when autodie was in scope, # and with what arguments, we also set a %^H hint which # is how we were called. # This feature should be considered EXPERIMENTAL, and # may change without notice. Please e-mail pjf@cpan.org # if you're actually using it. $^H{autodie} = "$PACKAGE @original_args"; } return; } # The code here is originally lifted from namespace::clean, # by Robert "phaylon" Sedlacek. # # It's been redesigned after feedback from ikegami on perlmonks. # See http://perlmonks.org/?node_id=693338 . Ikegami rocks. # # Given a package, and hash of (subname => subref) pairs, # we install the given subroutines into the package. If # a subref is undef, the subroutine is removed. Otherwise # it replaces any existing subs which were already there. sub _install_subs { my ($class, $pkg, $subs_to_reinstate) = @_; my $pkg_sym = "${pkg}::"; while(my ($sub_name, $sub_ref) = each %$subs_to_reinstate) { my $full_path = $pkg_sym.$sub_name; # Copy symbols across to temp area. no strict 'refs'; ## no critic local *__tmp = *{ $full_path }; # Nuke the old glob. { no strict; delete $pkg_sym->{$sub_name}; } ## no critic # Copy innocent bystanders back. Note that we lose # formats; it seems that Perl versions up to 5.10.0 # have a bug which causes copying formats to end up in # the scalar slot. Thanks to Ben Morrow for spotting this. foreach my $slot (qw( SCALAR ARRAY HASH IO ) ) { next unless defined *__tmp{ $slot }; *{ $full_path } = *__tmp{ $slot }; } # Put back the old sub (if there was one). if ($sub_ref) { no strict; ## no critic *{ $pkg_sym . $sub_name } = $sub_ref; } } return; } sub unimport { my $class = shift; # Calling "no Fatal" must start with ":lexical" if ($_[0] ne LEXICAL_TAG) { croak(sprintf(ERROR_NO_LEX,$class)); } shift @_; # Remove :lexical my $pkg = (caller)[0]; # If we've been called with arguments, then the developer # has explicitly stated 'no autodie qw(blah)', # in which case, we disable Fatalistic behaviour for 'blah'. my @unimport_these = @_ ? @_ : ':all'; while (my $symbol = shift @unimport_these) { if ($symbol =~ /^:/) { # Looks like a tag! Expand it! push(@unimport_these, @{ $TAGS{$symbol} }); next; } my $sub = $symbol; $sub = "${pkg}::$sub" unless $sub =~ /::/; # If 'blah' was already enabled with Fatal (which has package # scope) then, this is considered an error. if (exists $Package_Fatal{$sub}) { croak(sprintf(ERROR_AUTODIE_CONFLICT,$symbol,$symbol)); } # Record 'no autodie qw($sub)' as being in effect. # This is to catch conflicting semantics elsewhere # (eg, mixing Fatal with no autodie) $^H{$NO_PACKAGE}{$sub} = 1; if (my $original_sub = $Original_user_sub{$sub}) { # Hey, we've got an original one of these, put it back. $class->_install_subs($pkg, { $symbol => $original_sub }); next; } # We don't have an original copy of the sub, on the assumption # it's core (or doesn't exist), we'll just nuke it. $class->_install_subs($pkg,{ $symbol => undef }); } return; } # TODO - This is rather terribly inefficient right now. # NB: Perl::Critic's dump-autodie-tag-contents depends upon this # continuing to work. { my %tag_cache; sub _expand_tag { my ($class, $tag) = @_; if (my $cached = $tag_cache{$tag}) { return $cached; } if (not exists $TAGS{$tag}) { croak "Invalid exception class $tag"; } my @to_process = @{$TAGS{$tag}}; my @taglist = (); while (my $item = shift @to_process) { if ($item =~ /^:/) { # Expand :tags push(@to_process, @{$TAGS{$item}} ); } else { push(@taglist, "CORE::$item"); } } $tag_cache{$tag} = \@taglist; return \@taglist; } } # This code is from the original Fatal. It scares me. # It is 100% compatible with the 5.10.0 Fatal module, right down # to the scary 'XXXX' comment. ;) sub fill_protos { my $proto = shift; my ($n, $isref, @out, @out1, $seen_semi) = -1; while ($proto =~ /\S/) { $n++; push(@out1,[$n,@out]) if $seen_semi; push(@out, $1 . "{\$_[$n]}"), next if $proto =~ s/^\s*\\([\@%\$\&])//; push(@out, "\$_[$n]"), next if $proto =~ s/^\s*([_*\$&])//; push(@out, "\@_[$n..\$#_]"), last if $proto =~ s/^\s*(;\s*)?\@//; $seen_semi = 1, $n--, next if $proto =~ s/^\s*;//; # XXXX ???? die "Internal error: Unknown prototype letters: \"$proto\""; } push(@out1,[$n+1,@out]); return @out1; } # This is a backwards compatible version of _write_invocation. It's # recommended you don't use it. sub write_invocation { my ($core, $call, $name, $void, @args) = @_; return Fatal->_write_invocation( $core, $call, $name, $void, 0, # Lexical flag undef, # Sub, unused in legacy mode undef, # Subref, unused in legacy mode. @args ); } # This version of _write_invocation is used internally. It's not # recommended you call it from external code, as the interface WILL # change in the future. sub _write_invocation { my ($class, $core, $call, $name, $void, $lexical, $sub, $sref, @argvs) = @_; if (@argvs == 1) { # No optional arguments my @argv = @{$argvs[0]}; shift @argv; return $class->_one_invocation($core,$call,$name,$void,$sub,! $lexical, $sref, @argv); } else { my $else = "\t"; my (@out, @argv, $n); while (@argvs) { @argv = @{shift @argvs}; $n = shift @argv; my $condition = "\@_ == $n"; if (@argv and $argv[-1] =~ /#_/) { # This argv ends with '@' in the prototype, so it matches # any number of args >= the number of expressions in the # argv. $condition = "\@_ >= $n"; } push @out, "${else}if ($condition) {\n"; $else = "\t} els"; push @out, $class->_one_invocation($core,$call,$name,$void,$sub,! $lexical, $sref, @argv); } push @out, qq[ } die "Internal error: $name(\@_): Do not expect to get ", scalar(\@_), " arguments"; ]; return join '', @out; } } # This is a slim interface to ensure backward compatibility with # anyone doing very foolish things with old versions of Fatal. sub one_invocation { my ($core, $call, $name, $void, @argv) = @_; return Fatal->_one_invocation( $core, $call, $name, $void, undef, # Sub. Unused in back-compat mode. 1, # Back-compat flag undef, # Subref, unused in back-compat mode. @argv ); } # This is the internal interface that generates code. # NOTE: This interface WILL change in the future. Please do not # call this subroutine directly. # TODO: Whatever's calling this code has already looked up hints. Pass # them in, rather than look them up a second time. sub _one_invocation { my ($class, $core, $call, $name, $void, $sub, $back_compat, $sref, @argv) = @_; # If someone is calling us directly (a child class perhaps?) then # they could try to mix void without enabling backwards # compatibility. We just don't support this at all, so we gripe # about it rather than doing something unwise. if ($void and not $back_compat) { Carp::confess("Internal error: :void mode not supported with $class"); } # @argv only contains the results of the in-built prototype # function, and is therefore safe to interpolate in the # code generators below. # TODO - The following clobbers context, but that's what the # old Fatal did. Do we care? if ($back_compat) { # Use Fatal qw(system) will never be supported. It generated # a compile-time error with legacy Fatal, and there's no reason # to support it when autodie does a better job. if ($call eq 'CORE::system') { return q{ croak("UNIMPLEMENTED: use Fatal qw(system) not supported."); }; } local $" = ', '; if ($void) { return qq/return (defined wantarray)?$call(@argv): $call(@argv) || Carp::croak("Can't $name(\@_)/ . ($core ? ': $!' : ', \$! is \"$!\"') . '")' } else { return qq{return $call(@argv) || Carp::croak("Can't $name(\@_)} . ($core ? ': $!' : ', \$! is \"$!\"') . '")'; } } # The name of our original function is: # $call if the function is CORE # $sub if our function is non-CORE # The reason for this is that $call is what we're actualling # calling. For our core functions, this is always # CORE::something. However for user-defined subs, we're about to # replace whatever it is that we're calling; as such, we actually # calling a subroutine ref. my $human_sub_name = $core ? $call : $sub; # Should we be testing to see if our result is defined, or # just true? my $use_defined_or; my $hints; # All user-sub hints, including list hints. if ( $core ) { # Core hints are built into autodie. $use_defined_or = exists ( $Use_defined_or{$call} ); } else { # User sub hints are looked up using autodie::hints, # since users may wish to add their own hints. require autodie::hints; $hints = autodie::hints->get_hints_for( $sref ); # We'll look up the sub's fullname. This means we # get better reports of where it came from in our # error messages, rather than what imported it. $human_sub_name = autodie::hints->sub_fullname( $sref ); } # Checks for special core subs. if ($call eq 'CORE::system') { # Leverage IPC::System::Simple if we're making an autodying # system. local $" = ", "; # We need to stash $@ into $E, rather than using # local $@ for the whole sub. If we don't then # any exceptions from internal errors in autodie/Fatal # will mysteriously disappear before propogating # upwards. return qq{ my \$retval; my \$E; { local \$@; eval { \$retval = IPC::System::Simple::system(@argv); }; \$E = \$@; } if (\$E) { # TODO - This can't be overridden in child # classes! die autodie::exception::system->new( function => q{CORE::system}, args => [ @argv ], message => "\$E", errno => \$!, ); } return \$retval; }; } local $" = ', '; # If we're going to throw an exception, here's the code to use. my $die = qq{ die $class->throw( function => q{$human_sub_name}, args => [ @argv ], pragma => q{$class}, errno => \$!, context => \$context, return => \$retval, eval_error => \$@ ) }; if ($call eq 'CORE::flock') { # flock needs special treatment. When it fails with # LOCK_UN and EWOULDBLOCK, then it's not really fatal, it just # means we couldn't get the lock right now. require POSIX; # For POSIX::EWOULDBLOCK local $@; # Don't blat anyone else's $@. # Ensure that our vendor supports EWOULDBLOCK. If they # don't (eg, Windows), then we use known values for its # equivalent on other systems. my $EWOULDBLOCK = eval { POSIX::EWOULDBLOCK(); } || $_EWOULDBLOCK{$^O} || _autocroak("Internal error - can't overload flock - EWOULDBLOCK not defined on this system."); my $EAGAIN = $EWOULDBLOCK; if ($try_EAGAIN) { $EAGAIN = eval { POSIX::EAGAIN(); } || _autocroak("Internal error - can't overload flock - EAGAIN not defined on this system."); } require Fcntl; # For Fcntl::LOCK_NB return qq{ my \$context = wantarray() ? "list" : "scalar"; # Try to flock. If successful, return it immediately. my \$retval = $call(@argv); return \$retval if \$retval; # If we failed, but we're using LOCK_NB and # returned EWOULDBLOCK, it's not a real error. if (\$_[1] & Fcntl::LOCK_NB() and (\$! == $EWOULDBLOCK or ($try_EAGAIN and \$! == $EAGAIN ))) { return \$retval; } # Otherwise, we failed. Die noisily. $die; }; } # AFAIK everything that can be given an unopned filehandle # will fail if it tries to use it, so we don't really need # the 'unopened' warning class here. Especially since they # then report the wrong line number. # Other warnings are disabled because they produce excessive # complaints from smart-match hints under 5.10.1. my $code = qq[ no warnings qw(unopened uninitialized numeric); if (wantarray) { my \@results = $call(@argv); my \$retval = \\\@results; my \$context = "list"; ]; my $retval_action = $Retval_action{$call} || ''; if ( $hints and ( ref($hints->{list} ) || "" ) eq 'CODE' ) { # NB: Subroutine hints are passed as a full list. # This differs from the 5.10.0 smart-match behaviour, # but means that context unaware subroutines can use # the same hints in both list and scalar context. $code .= qq{ if ( \$hints->{list}->(\@results) ) { $die }; }; } elsif ( PERL510 and $hints ) { $code .= qq{ if ( \@results ~~ \$hints->{list} ) { $die }; }; } elsif ( $hints ) { croak sprintf(ERROR_58_HINTS, 'list', $sub); } else { $code .= qq{ # An empty list, or a single undef is failure if (! \@results or (\@results == 1 and ! defined \$results[0])) { $die; } } } # Tidy up the end of our wantarray call. $code .= qq[ return \@results; } ]; # Otherwise, we're in scalar context. # We're never in a void context, since we have to look # at the result. $code .= qq{ my \$retval = $call(@argv); my \$context = "scalar"; }; if ( $hints and ( ref($hints->{scalar} ) || "" ) eq 'CODE' ) { # We always call code refs directly, since that always # works in 5.8.x, and always works in 5.10.1 return $code .= qq{ if ( \$hints->{scalar}->(\$retval) ) { $die }; $retval_action return \$retval; }; } elsif (PERL510 and $hints) { return $code . qq{ if ( \$retval ~~ \$hints->{scalar} ) { $die }; $retval_action return \$retval; }; } elsif ( $hints ) { croak sprintf(ERROR_58_HINTS, 'scalar', $sub); } return $code . ( $use_defined_or ? qq{ $die if not defined \$retval; $retval_action return \$retval; } : qq{ $retval_action return \$retval || $die; } ) ; } # This returns the old copy of the sub, so we can # put it back at end of scope. # TODO : Check to make sure prototypes are restored correctly. # TODO: Taking a huge list of arguments is awful. Rewriting to # take a hash would be lovely. # TODO - BACKCOMPAT - This is not yet compatible with 5.10.0 sub _make_fatal { my($class, $sub, $pkg, $void, $lexical, $filename, $insist) = @_; my($name, $code, $sref, $real_proto, $proto, $core, $call, $hints); my $ini = $sub; $sub = "${pkg}::$sub" unless $sub =~ /::/; # Figure if we're using lexical or package semantics and # twiddle the appropriate bits. if (not $lexical) { $Package_Fatal{$sub} = 1; } # TODO - We *should* be able to do skipping, since we know when # we've lexicalised / unlexicalised a subroutine. $name = $sub; $name =~ s/.*::// or $name =~ s/^&//; warn "# _make_fatal: sub=$sub pkg=$pkg name=$name void=$void\n" if $Debug; croak(sprintf(ERROR_BADNAME, $class, $name)) unless $name =~ /^\w+$/; if (defined(&$sub)) { # user subroutine # NOTE: Previously we would localise $@ at this point, so # the following calls to eval {} wouldn't interfere with anything # that's already in $@. Unfortunately, it would also stop # any of our croaks from triggering(!), which is even worse. # This could be something that we've fatalised that # was in core. if ( $Package_Fatal{$sub} and do { local $@; eval { prototype "CORE::$name" } } ) { # Something we previously made Fatal that was core. # This is safe to replace with an autodying to core # version. $core = 1; $call = "CORE::$name"; $proto = prototype $call; # We return our $sref from this subroutine later # on, indicating this subroutine should be placed # back when we're finished. $sref = \&$sub; } else { # If this is something we've already fatalised or played with, # then look-up the name of the original sub for the rest of # our processing. $sub = $Is_fatalised_sub{\&$sub} || $sub; # A regular user sub, or a user sub wrapping a # core sub. $sref = \&$sub; $proto = prototype $sref; $call = '&$sref'; require autodie::hints; $hints = autodie::hints->get_hints_for( $sref ); # If we've insisted on hints, but don't have them, then # bail out! if ($insist and not $hints) { croak(sprintf(ERROR_NOHINTS, $name)); } # Otherwise, use the default hints if we don't have # any. $hints ||= autodie::hints::DEFAULT_HINTS(); } } elsif ($sub eq $ini && $sub !~ /^CORE::GLOBAL::/) { # Stray user subroutine croak(sprintf(ERROR_NOTSUB,$sub)); } elsif ($name eq 'system') { # If we're fatalising system, then we need to load # helper code. # The business with $E is to avoid clobbering our caller's # $@, and to avoid $@ being localised when we croak. my $E; { local $@; eval { require IPC::System::Simple; # Only load it if we need it. require autodie::exception::system; }; $E = $@; } if ($E) { croak ERROR_NO_IPC_SYS_SIMPLE; } # Make sure we're using a recent version of ISS that actually # support fatalised system. if ($IPC::System::Simple::VERSION < MIN_IPC_SYS_SIMPLE_VER) { croak sprintf( ERROR_IPC_SYS_SIMPLE_OLD, MIN_IPC_SYS_SIMPLE_VER, $IPC::System::Simple::VERSION ); } $call = 'CORE::system'; $name = 'system'; $core = 1; } elsif ($name eq 'exec') { # Exec doesn't have a prototype. We don't care. This # breaks the exotic form with lexical scope, and gives # the regular form a "do or die" beaviour as expected. $call = 'CORE::exec'; $name = 'exec'; $core = 1; } else { # CORE subroutine my $E; { local $@; $proto = eval { prototype "CORE::$name" }; $E = $@; } croak(sprintf(ERROR_NOT_BUILT,$name)) if $E; croak(sprintf(ERROR_CANT_OVERRIDE,$name)) if not defined $proto; $core = 1; $call = "CORE::$name"; } if (defined $proto) { $real_proto = " ($proto)"; } else { $real_proto = ''; $proto = '@'; } my $true_name = $core ? $call : $sub; # TODO: This caching works, but I don't like using $void and # $lexical as keys. In particular, I suspect our code may end up # wrapping already wrapped code when autodie and Fatal are used # together. # NB: We must use '$sub' (the name plus package) and not # just '$name' (the short name) here. Failing to do so # results code that's in the wrong package, and hence has # access to the wrong package filehandles. if (my $subref = $Cached_fatalised_sub{$class}{$sub}{$void}{$lexical}) { $class->_install_subs($pkg, { $name => $subref }); return $sref; } $code = qq[ sub$real_proto { local(\$", \$!) = (', ', 0); # TODO - Why do we do this? ]; # Don't have perl whine if exec fails, since we'll be handling # the exception now. $code .= "no warnings qw(exec);\n" if $call eq "CORE::exec"; my @protos = fill_protos($proto); $code .= $class->_write_invocation($core, $call, $name, $void, $lexical, $sub, $sref, @protos); $code .= "}\n"; warn $code if $Debug; # I thought that changing package was a monumental waste of # time for CORE subs, since they'll always be the same. However # that's not the case, since they may refer to package-based # filehandles (eg, with open). # # There is potential to more aggressively cache core subs # that we know will never want to interact with package variables # and filehandles. { no strict 'refs'; ## no critic # to avoid: Can't use string (...) as a symbol ref ... my $E; { local $@; $code = eval("package $pkg; require Carp; $code"); ## no critic $E = $@; } if (not $code) { croak("Internal error in autodie/Fatal processing $true_name: $E"); } } # Now we need to wrap our fatalised sub inside an itty bitty # closure, which can detect if we've leaked into another file. # Luckily, we only need to do this for lexical (autodie) # subs. Fatal subs can leak all they want, it's considered # a "feature" (or at least backwards compatible). # TODO: Cache our leak guards! # TODO: This is pretty hairy code. A lot more tests would # be really nice for this. my $leak_guard; if ($lexical) { $leak_guard = qq< package $pkg; sub$real_proto { # If we're inside a string eval, we can end up with a # whacky filename. The following code allows autodie # to propagate correctly into string evals. my \$caller_level = 0; my \$caller; while ( (\$caller = (caller \$caller_level)[1]) =~ m{^\\(eval \\d+\\)\$} ) { # If our filename is actually an eval, and we # reach it, then go to our autodying code immediatately. goto &\$code if (\$caller eq \$filename); \$caller_level++; } # We're now out of the eval stack. # If we're called from the correct file, then use the # autodying code. goto &\$code if ((caller \$caller_level)[1] eq \$filename); # Oh bother, we've leaked into another file. Call the # original code. Note that \$sref may actually be a # reference to a Fatalised version of a core built-in. # That's okay, because Fatal *always* leaks between files. goto &\$sref if \$sref; >; # If we're here, it must have been a core subroutine called. # Warning: The following code may disturb some viewers. # TODO: It should be possible to combine this with # write_invocation(). foreach my $proto (@protos) { local $" = ", "; # So @args is formatted correctly. my ($count, @args) = @$proto; $leak_guard .= qq< if (\@_ == $count) { return $call(@args); } >; } $leak_guard .= qq< Carp::croak("Internal error in Fatal/autodie. Leak-guard failure"); } >; # warn "$leak_guard\n"; my $E; { local $@; $leak_guard = eval $leak_guard; ## no critic $E = $@; } die "Internal error in $class: Leak-guard installation failure: $E" if $E; } my $installed_sub = $leak_guard || $code; $class->_install_subs($pkg, { $name => $installed_sub }); $Cached_fatalised_sub{$class}{$sub}{$void}{$lexical} = $installed_sub; # Cache that we've now overriddent this sub. If we get called # again, we may need to find that find subroutine again (eg, for hints). $Is_fatalised_sub{$installed_sub} = $sref; return $sref; } # This subroutine exists primarily so that child classes can override # it to point to their own exception class. Doing this is significantly # less complex than overriding throw() sub exception_class { return "autodie::exception" }; { my %exception_class_for; my %class_loaded; sub throw { my ($class, @args) = @_; # Find our exception class if we need it. my $exception_class = $exception_class_for{$class} ||= $class->exception_class; if (not $class_loaded{$exception_class}) { if ($exception_class =~ /[^\w:']/) { confess "Bad exception class '$exception_class'.\nThe '$class->exception_class' method wants to use $exception_class\nfor exceptions, but it contains characters which are not word-characters or colons."; } # Alas, Perl does turn barewords into modules unless they're # actually barewords. As such, we're left doing a string eval # to make sure we load our file correctly. my $E; { local $@; # We can't clobber $@, it's wrong! my $pm_file = $exception_class . ".pm"; $pm_file =~ s{ (?: :: | ' ) }{/}gx; eval { require $pm_file }; $E = $@; # Save $E despite ending our local. } # We need quotes around $@ to make sure it's stringified # while still in scope. Without them, we run the risk of # $@ having been cleared by us exiting the local() block. confess "Failed to load '$exception_class'.\nThis may be a typo in the '$class->exception_class' method,\nor the '$exception_class' module may not exist.\n\n $E" if $E; $class_loaded{$exception_class}++; } return $exception_class->new(@args); } } # For some reason, dying while replacing our subs doesn't # kill our calling program. It simply stops the loading of # autodie and keeps going with everything else. The _autocroak # sub allows us to die with a vegence. It should *only* ever be # used for serious internal errors, since the results of it can't # be captured. sub _autocroak { warn Carp::longmess(@_); exit(255); # Ugh! } package autodie::Scope::Guard; # This code schedules the cleanup of subroutines at the end of # scope. It's directly inspired by chocolateboy's excellent # Scope::Guard module. sub new { my ($class, $handler) = @_; return bless $handler, $class; } sub DESTROY { my ($self) = @_; $self->(); } 1; __END__ =head1 NAME Fatal - Replace functions with equivalents which succeed or die =head1 SYNOPSIS use Fatal qw(open close); open(my $fh, "<", $filename); # No need to check errors! use File::Copy qw(move); use Fatal qw(move); move($file1, $file2); # No need to check errors! sub juggle { . . . } Fatal->import('juggle'); =head1 BEST PRACTICE B<Fatal has been obsoleted by the new L<autodie> pragma.> Please use L<autodie> in preference to C<Fatal>. L<autodie> supports lexical scoping, throws real exception objects, and provides much nicer error messages. The use of C<:void> with Fatal is discouraged. =head1 DESCRIPTION C<Fatal> provides a way to conveniently replace functions which normally return a false value when they fail with equivalents which raise exceptions if they are not successful. This lets you use these functions without having to test their return values explicitly on each call. Exceptions can be caught using C<eval{}>. See L<perlfunc> and L<perlvar> for details. The do-or-die equivalents are set up simply by calling Fatal's C<import> routine, passing it the names of the functions to be replaced. You may wrap both user-defined functions and overridable CORE operators (except C<exec>, C<system>, C<print>, or any other built-in that cannot be expressed via prototypes) in this way. If the symbol C<:void> appears in the import list, then functions named later in that import list raise an exception only when these are called in void context--that is, when their return values are ignored. For example use Fatal qw/:void open close/; # properly checked, so no exception raised on error if (not open(my $fh, '<', '/bogotic') { warn "Can't open /bogotic: $!"; } # not checked, so error raises an exception close FH; The use of C<:void> is discouraged, as it can result in exceptions not being thrown if you I<accidentally> call a method without void context. Use L<autodie> instead if you need to be able to disable autodying/Fatal behaviour for a small block of code. =head1 DIAGNOSTICS =over 4 =item Bad subroutine name for Fatal: %s You've called C<Fatal> with an argument that doesn't look like a subroutine name, nor a switch that this version of Fatal understands. =item %s is not a Perl subroutine You've asked C<Fatal> to try and replace a subroutine which does not exist, or has not yet been defined. =item %s is neither a builtin, nor a Perl subroutine You've asked C<Fatal> to replace a subroutine, but it's not a Perl built-in, and C<Fatal> couldn't find it as a regular subroutine. It either doesn't exist or has not yet been defined. =item Cannot make the non-overridable %s fatal You've tried to use C<Fatal> on a Perl built-in that can't be overridden, such as C<print> or C<system>, which means that C<Fatal> can't help you, although some other modules might. See the L</"SEE ALSO"> section of this documentation. =item Internal error: %s You've found a bug in C<Fatal>. Please report it using the C<perlbug> command. =back =head1 BUGS C<Fatal> clobbers the context in which a function is called and always makes it a scalar context, except when the C<:void> tag is used. This problem does not exist in L<autodie>. "Used only once" warnings can be generated when C<autodie> or C<Fatal> is used with package filehandles (eg, C<FILE>). It's strongly recommended you use scalar filehandles instead. =head1 AUTHOR Original module by Lionel Cons (CERN). Prototype updates by Ilya Zakharevich <ilya@math.ohio-state.edu>. L<autodie> support, bugfixes, extended diagnostics, C<system> support, and major overhauling by Paul Fenwick <pjf@perltraining.com.au> =head1 LICENSE This module is free software, you may distribute it under the same terms as Perl itself. =head1 SEE ALSO L<autodie> for a nicer way to use lexical Fatal. L<IPC::System::Simple> for a similar idea for calls to C<system()> and backticks. =cut
amidoimidazol/bio_info
Beginning Perl for Bioinformatics/lib/Fatal.pm
Perl
mit
44,435
#!/usr/bin/perl -w package fqpair; use strict; use warnings; # fqpair.pm # Sanzhen Liu # 9/15/2020 sub fqpair { # input two paired fastq # output 1 or 0 to indicate if two fq were paired or not. my ($infq1, $infq2) = @_; my (@read1, @read2); ### pair 1 my $row = 0; open(IN, $infq1) || die; while (<IN>) { chomp; if (/^\@(\S+)/ and ($row % 4) == 0) { my $common_name = $1; $common_name =~ s/\/[1-2]$//; push(@read1, $common_name); } $row++; } close IN; ### pair2 $row = 0; open(IN, $infq2) || die; while (<IN>) { chomp; if (/^\@(\S+)/ and ($row % 4) == 0) { my $common_name = $1; $common_name =~ s/\/[1-2]$//; push(@read2, $common_name); } $row++; } close IN; # paired my $well_paired = 1; if ($#read1 != $#read2) { $well_paired = 0; } else { # compared each name for (my $i=0; $i<=$#read1; $i++) { if ($read1[$i] ne $read2[$i]) { $well_paired = 0; last; } } } # output return $well_paired; } 1;
liu3zhenlab/scripts
k-mer/k2readasm/lib/fqpair.pm
Perl
mit
983
#!/usr/bin/perl use warnings; use strict; use feature 'say'; my $fname = shift; open my $fh, "<", $fname or die "Can't open $fname: $!"; my $line = <$fh>; chomp $line; my @p = split /,/, $line; my $step; my $radiatiorID = 5; my $i = 0; while (1) { my $instr = $p[$i]; my $opcode; my @modes = ( 0, 0, 0 ); if ( length $instr > 2 ) { $opcode = substr( $instr, -1 ); @modes = reverse split //, $instr =~ s/..$//r; push @modes, 0 while @modes < 3; } else { $opcode = $instr; } last if $opcode == 99; if ( $opcode == 1 ) { # addition my $arg1 = $modes[0] == 0 ? $p[ $p[ $i + 1 ] ] : $p[ $i + 1 ]; my $arg2 = $modes[1] == 0 ? $p[ $p[ $i + 2 ] ] : $p[ $i + 2 ]; $p[ $p[ $i + 3 ] ] = $arg1 + $arg2; $step = 4; } elsif ( $opcode == 2 ) { # multiplication my $arg1 = $modes[0] == 0 ? $p[ $p[ $i + 1 ] ] : $p[ $i + 1 ]; my $arg2 = $modes[1] == 0 ? $p[ $p[ $i + 2 ] ] : $p[ $i + 2 ]; $p[ $p[ $i + 3 ] ] = $arg1 * $arg2; $step = 4; } elsif ( $opcode == 3 ) { # input $p[ $p[ $i + 1 ] ] = $radiatiorID; $step = 2; } elsif ( $opcode == 4 ) { # output my $arg1 = $modes[0] == 0 ? $p[ $p[ $i + 1 ] ] : $p[ $i + 1 ]; say $arg1; $step = 2; } elsif ( $opcode == 5 ) { # jump-if-true my $arg1 = $modes[0] == 0 ? $p[ $p[ $i + 1 ] ] : $p[ $i + 1 ]; my $arg2 = $modes[1] == 0 ? $p[ $p[ $i + 2 ] ] : $p[ $i + 2 ]; if ( $arg1 != 0 ) { $i = $arg2; $step = 0; } else { $step = 3; } } elsif ( $opcode == 6 ) { # jump-if-false my $arg1 = $modes[0] == 0 ? $p[ $p[ $i + 1 ] ] : $p[ $i + 1 ]; my $arg2 = $modes[1] == 0 ? $p[ $p[ $i + 2 ] ] : $p[ $i + 2 ]; if ( $arg1 == 0 ) { $i = $arg2; $step = 0; } else { $step = 3; } } elsif ( $opcode == 7 ) { # less-than my $arg1 = $modes[0] == 0 ? $p[ $p[ $i + 1 ] ] : $p[ $i + 1 ]; my $arg2 = $modes[1] == 0 ? $p[ $p[ $i + 2 ] ] : $p[ $i + 2 ]; $p[ $p[ $i + 3 ] ] = $arg1 < $arg2 ? 1 : 0; $step = 4; } elsif ( $opcode == 8 ) { # equals my $arg1 = $modes[0] == 0 ? $p[ $p[ $i + 1 ] ] : $p[ $i + 1 ]; my $arg2 = $modes[1] == 0 ? $p[ $p[ $i + 2 ] ] : $p[ $i + 2 ]; $p[ $p[ $i + 3 ] ] = $arg1 == $arg2 ? 1 : 0; $step = 4; } else { die "illegal opcode at index $i: $opcode"; } $i += $step; }
bewuethr/advent_of_code
2019/day05/day05b.pl
Perl
mit
2,629
package Pdbc::Operator; use strict; use warnings FATAL => 'all'; use v5.19; use feature qw(signatures); no warnings qw(experimental::signatures); use Exporter; our (@ISA, @EXPORT); @ISA = qw(Exporter); @EXPORT = qw(EQUAL NOT_EQUAL LIKE IS_NULL IS_NOT_NULL); use overload ( q{""} => \&as_string, fallback => 1, ); sub __new($pkg, $scalar, $has_value) { return bless { scalar => $scalar, has_value => $has_value }, $pkg; } sub has_value($self) { return $self->{has_value} } sub as_string { my $self = shift; return $self->{scalar}; } sub EQUAL { return Pdbc::Operator->__new('=', 1); } sub NOT_EQUAL { return Pdbc::Operator->__new('<>', 1); } sub LIKE { return Pdbc::Operator->__new('LIKE', 1); } sub IS_NULL { return Pdbc::Operator->__new('IS NULL', undef); } sub IS_NOT_NULL { return Pdbc::Operator->__new('IS NOT NULL', undef); } 1;
duck8823/pdbc-manager
lib/Pdbc/Operator.pm
Perl
mit
861
# 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/europe. Olson data version 2008c # # Do not edit this file directly. # package DateTime::TimeZone::Europe::Volgograd; use strict; use Class::Singleton; use DateTime::TimeZone; use DateTime::TimeZone::OlsonDB; @DateTime::TimeZone::Europe::Volgograd::ISA = ( 'Class::Singleton', 'DateTime::TimeZone' ); my $spans = [ [ DateTime::TimeZone::NEG_INFINITY, 60557922140, DateTime::TimeZone::NEG_INFINITY, 60557932800, 10660, 0, 'LMT' ], [ 60557922140, 60723810000, 60557932940, 60723820800, 10800, 0, 'TSAT' ], [ 60723810000, 60888142800, 60723820800, 60888153600, 10800, 0, 'STAT' ], [ 60888142800, 61878801600, 60888157200, 61878816000, 14400, 0, 'STAT' ], [ 61878801600, 62490600000, 61878816000, 62490614400, 14400, 0, 'VOLT' ], [ 62490600000, 62506407600, 62490618000, 62506425600, 18000, 1, 'VOLST' ], [ 62506407600, 62522136000, 62506422000, 62522150400, 14400, 0, 'VOLT' ], [ 62522136000, 62537943600, 62522154000, 62537961600, 18000, 1, 'VOLST' ], [ 62537943600, 62553672000, 62537958000, 62553686400, 14400, 0, 'VOLT' ], [ 62553672000, 62569479600, 62553690000, 62569497600, 18000, 1, 'VOLST' ], [ 62569479600, 62585294400, 62569494000, 62585308800, 14400, 0, 'VOLT' ], [ 62585294400, 62601026400, 62585312400, 62601044400, 18000, 1, 'VOLST' ], [ 62601026400, 62616751200, 62601040800, 62616765600, 14400, 0, 'VOLT' ], [ 62616751200, 62632476000, 62616769200, 62632494000, 18000, 1, 'VOLST' ], [ 62632476000, 62648200800, 62632490400, 62648215200, 14400, 0, 'VOLT' ], [ 62648200800, 62663925600, 62648218800, 62663943600, 18000, 1, 'VOLST' ], [ 62663925600, 62679650400, 62663940000, 62679664800, 14400, 0, 'VOLT' ], [ 62679650400, 62695375200, 62679668400, 62695393200, 18000, 1, 'VOLST' ], [ 62695375200, 62711100000, 62695389600, 62711114400, 14400, 0, 'VOLT' ], [ 62711100000, 62726824800, 62711118000, 62726842800, 18000, 1, 'VOLST' ], [ 62726824800, 62742549600, 62726839200, 62742564000, 14400, 0, 'VOLT' ], [ 62742549600, 62758278000, 62742564000, 62758292400, 14400, 1, 'VOLST' ], [ 62758278000, 62774002800, 62758288800, 62774013600, 10800, 0, 'VOLT' ], [ 62774002800, 62790332400, 62774017200, 62790346800, 14400, 1, 'VOLST' ], [ 62790332400, 62806057200, 62790343200, 62806068000, 10800, 0, 'VOLT' ], [ 62806057200, 62837503200, 62806071600, 62837517600, 14400, 0, 'VOLT' ], [ 62837503200, 62853217200, 62837517600, 62853231600, 14400, 1, 'VOLST' ], [ 62853217200, 62868956400, 62853228000, 62868967200, 10800, 0, 'VOLT' ], [ 62868956400, 62884681200, 62868970800, 62884695600, 14400, 1, 'VOLST' ], [ 62884681200, 62900406000, 62884692000, 62900416800, 10800, 0, 'VOLT' ], [ 62900406000, 62916130800, 62900420400, 62916145200, 14400, 1, 'VOLST' ], [ 62916130800, 62931855600, 62916141600, 62931866400, 10800, 0, 'VOLT' ], [ 62931855600, 62947580400, 62931870000, 62947594800, 14400, 1, 'VOLST' ], [ 62947580400, 62963910000, 62947591200, 62963920800, 10800, 0, 'VOLT' ], [ 62963910000, 62982054000, 62963924400, 62982068400, 14400, 1, 'VOLST' ], [ 62982054000, 62995359600, 62982064800, 62995370400, 10800, 0, 'VOLT' ], [ 62995359600, 63013503600, 62995374000, 63013518000, 14400, 1, 'VOLST' ], [ 63013503600, 63026809200, 63013514400, 63026820000, 10800, 0, 'VOLT' ], [ 63026809200, 63044953200, 63026823600, 63044967600, 14400, 1, 'VOLST' ], [ 63044953200, 63058258800, 63044964000, 63058269600, 10800, 0, 'VOLT' ], [ 63058258800, 63077007600, 63058273200, 63077022000, 14400, 1, 'VOLST' ], [ 63077007600, 63089708400, 63077018400, 63089719200, 10800, 0, 'VOLT' ], [ 63089708400, 63108457200, 63089722800, 63108471600, 14400, 1, 'VOLST' ], [ 63108457200, 63121158000, 63108468000, 63121168800, 10800, 0, 'VOLT' ], [ 63121158000, 63139906800, 63121172400, 63139921200, 14400, 1, 'VOLST' ], [ 63139906800, 63153212400, 63139917600, 63153223200, 10800, 0, 'VOLT' ], [ 63153212400, 63171356400, 63153226800, 63171370800, 14400, 1, 'VOLST' ], [ 63171356400, 63184662000, 63171367200, 63184672800, 10800, 0, 'VOLT' ], [ 63184662000, 63202806000, 63184676400, 63202820400, 14400, 1, 'VOLST' ], [ 63202806000, 63216111600, 63202816800, 63216122400, 10800, 0, 'VOLT' ], [ 63216111600, 63234860400, 63216126000, 63234874800, 14400, 1, 'VOLST' ], [ 63234860400, 63247561200, 63234871200, 63247572000, 10800, 0, 'VOLT' ], [ 63247561200, 63266310000, 63247575600, 63266324400, 14400, 1, 'VOLST' ], [ 63266310000, 63279010800, 63266320800, 63279021600, 10800, 0, 'VOLT' ], [ 63279010800, 63297759600, 63279025200, 63297774000, 14400, 1, 'VOLST' ], [ 63297759600, 63310460400, 63297770400, 63310471200, 10800, 0, 'VOLT' ], [ 63310460400, 63329209200, 63310474800, 63329223600, 14400, 1, 'VOLST' ], [ 63329209200, 63342514800, 63329220000, 63342525600, 10800, 0, 'VOLT' ], [ 63342514800, 63360658800, 63342529200, 63360673200, 14400, 1, 'VOLST' ], [ 63360658800, 63373964400, 63360669600, 63373975200, 10800, 0, 'VOLT' ], [ 63373964400, 63392108400, 63373978800, 63392122800, 14400, 1, 'VOLST' ], [ 63392108400, 63405414000, 63392119200, 63405424800, 10800, 0, 'VOLT' ], [ 63405414000, 63424162800, 63405428400, 63424177200, 14400, 1, 'VOLST' ], [ 63424162800, 63436863600, 63424173600, 63436874400, 10800, 0, 'VOLT' ], [ 63436863600, 63455612400, 63436878000, 63455626800, 14400, 1, 'VOLST' ], [ 63455612400, 63468313200, 63455623200, 63468324000, 10800, 0, 'VOLT' ], [ 63468313200, 63487062000, 63468327600, 63487076400, 14400, 1, 'VOLST' ], [ 63487062000, 63500367600, 63487072800, 63500378400, 10800, 0, 'VOLT' ], [ 63500367600, 63518511600, 63500382000, 63518526000, 14400, 1, 'VOLST' ], [ 63518511600, 63531817200, 63518522400, 63531828000, 10800, 0, 'VOLT' ], [ 63531817200, 63549961200, 63531831600, 63549975600, 14400, 1, 'VOLST' ], [ 63549961200, 63563266800, 63549972000, 63563277600, 10800, 0, 'VOLT' ], [ 63563266800, 63581410800, 63563281200, 63581425200, 14400, 1, 'VOLST' ], [ 63581410800, 63594716400, 63581421600, 63594727200, 10800, 0, 'VOLT' ], [ 63594716400, 63613465200, 63594730800, 63613479600, 14400, 1, 'VOLST' ], [ 63613465200, 63626166000, 63613476000, 63626176800, 10800, 0, 'VOLT' ], [ 63626166000, 63644914800, 63626180400, 63644929200, 14400, 1, 'VOLST' ], [ 63644914800, 63657615600, 63644925600, 63657626400, 10800, 0, 'VOLT' ], [ 63657615600, 63676364400, 63657630000, 63676378800, 14400, 1, 'VOLST' ], [ 63676364400, 63689670000, 63676375200, 63689680800, 10800, 0, 'VOLT' ], [ 63689670000, 63707814000, 63689684400, 63707828400, 14400, 1, 'VOLST' ], ]; sub olson_version { '2008c' } sub has_dst_changes { 38 } sub _max_year { 2018 } sub _new_instance { return shift->_init( @_, spans => $spans ); } sub _last_offset { 10800 } my $last_observance = bless( { 'format' => 'VOL%sT', 'gmtoff' => '3:00', 'local_start_datetime' => bless( { 'formatter' => undef, 'local_rd_days' => 727286, 'local_rd_secs' => 7200, 'offset_modifier' => 0, 'rd_nanosecs' => 0, 'tz' => bless( { 'name' => 'floating', 'offset' => 0 }, 'DateTime::TimeZone::Floating' ), 'utc_rd_days' => 727286, 'utc_rd_secs' => 7200, 'utc_year' => 1993 }, 'DateTime' ), 'offset_from_std' => 0, 'offset_from_utc' => 10800, 'until' => [], 'utc_start_datetime' => bless( { 'formatter' => undef, 'local_rd_days' => 727285, 'local_rd_secs' => 79200, 'offset_modifier' => 0, 'rd_nanosecs' => 0, 'tz' => bless( { 'name' => 'floating', 'offset' => 0 }, 'DateTime::TimeZone::Floating' ), 'utc_rd_days' => 727285, 'utc_rd_secs' => 79200, 'utc_year' => 1993 }, 'DateTime' ) }, 'DateTime::TimeZone::OlsonDB::Observance' ) ; sub _last_observance { $last_observance } my $rules = [ bless( { 'at' => '2:00s', 'from' => '1996', 'in' => 'Oct', 'letter' => '', 'name' => 'Russia', 'offset_from_std' => 0, 'on' => 'lastSun', 'save' => '0', 'to' => 'max', 'type' => undef }, 'DateTime::TimeZone::OlsonDB::Rule' ), bless( { 'at' => '2:00s', 'from' => '1993', 'in' => 'Mar', 'letter' => 'S', 'name' => 'Russia', 'offset_from_std' => 3600, 'on' => 'lastSun', 'save' => '1:00', 'to' => 'max', 'type' => undef }, 'DateTime::TimeZone::OlsonDB::Rule' ) ] ; sub _rules { $rules } 1;
carlgao/lenga
images/lenny64-peon/usr/share/perl5/DateTime/TimeZone/Europe/Volgograd.pm
Perl
mit
9,051
package ActivePerl::PPM::Arch; use strict; use base 'Exporter'; our @EXPORT_OK = qw(arch short_arch full_arch pretty_arch versioned_arch osname @archs); use Config qw(%Config); sub versioned_arch { my($arch,$version) = @_; return undef unless $arch; if ($version >= 5.008) { $arch .= sprintf "-%d.%d", int($version), int(($version-int($version))*1000); } return $arch; } sub arch { return versioned_arch($Config{archname}, $]); } sub short_arch { my $arch = shift || arch(); 1 while $arch =~ s/-(thread|multi|2level)//; return $arch; } sub full_arch { my $arch = shift; return $arch if $arch =~ /-thread\b/; my $perl = ""; $perl = $1 if $arch =~ s/(-5\.\d\d?)$//; return "$arch-thread-multi-2level$perl" if $arch =~ /^darwin/; return "$arch-multi-thread$perl" if $arch =~ /^MSWin/; return "$arch-thread-multi$perl"; } sub osname { my $arch = shift || arch(); for (qw(MSWin32 darwin aix linux solaris)) { return $_ if index($arch, $_) >= 0; } return "" if $arch eq "noarch"; return "hpux"; # the odd one } sub pretty_arch { my $arch = shift || arch(); 1 while $arch =~ s/-(thread|multi|2level)//; my $perl = "5.6"; $perl = $1 if $arch =~ s/-(5\.\d\d?)$//; if ($arch eq "darwin") { $arch = "Mac OS X"; } elsif ($arch eq "aix") { $arch = "AIX"; } elsif ($arch =~ /^MSWin32-x(86|64)$/) { $arch = "Windows"; $arch .= " 64" if $1 eq "64"; } elsif ($arch =~ /^(i686|x86_64|ia64)-linux$/) { my $cpu = $1; $cpu = "x86" if $cpu eq "i686"; $cpu = "IA64" if $cpu eq "ia64"; $arch = "Linux ($cpu)"; } elsif ($arch =~ /^(x86|sun4)-solaris(-64)?$/) { $arch = "Solaris"; $arch .= " 64" if $2; my $cpu = $1; $cpu = "SPARC" if $cpu eq "sun4"; $arch .= " ($cpu)"; } elsif ($arch =~ /^(IA64\.ARCHREV_0|PA-RISC\d+\.\d+)(-LP64)?$/) { $arch = "HP-UX"; $arch .= " 64" if $2; my $cpu = $1; $cpu = "IA64" if $cpu =~ /^IA64/; $cpu =~ s/(?<=^PA-RISC)/ /; $arch .= " ($cpu)"; } elsif ($arch eq "noarch") { return "ActivePerl" if $perl eq "5.6"; return "ActivePerl $perl (and later)"; } else { $arch = ucfirst($arch); # lame } return "ActivePerl $perl on $arch"; } our @archs = qw( MSWin32-x86 MSWin32-x64 darwin i686-linux x86_64-linux ia64-linux sun4-solaris sun4-solaris-64 x86-solaris x86-solaris-64 PA-RISC1.1 PA-RISC2.0-LP64 IA64.ARCHREV_0 IA64.ARCHREV_0-LP64 aix ); 1; __END__ =head1 NAME ActivePerl::PPM::Arch - Get current architecture identification =head1 DESCRIPTION The following functions are provided: =over =item arch() Returns the string that PPM use to identify the architecture of the current perl. This is what goes into the NAME attribute of the ARCHITECTURE element of the PPD files; see L<ActivePerl::PPM::PPD>. This is L<$Config{archname}> with the perl major version number appended. =item short_arch() =item short_arch( $arch ) This is the shorteded architecture string; dropping the segments for features that will always be enabled for ActivePerl ("thread", "multi", "2level"). Used to form the URL for the PPM CPAN repositories provided by ActiveState. =item full_arch( $short_arch ) Convert back from a short arch string to a full one. If the passed arch string is already full it's returned unchanged. =item pretty_arch() =item pretty_arch( $arch ) Returns a more human readable form of arch(). Will be a string on the form: "ActivePerl 5.10 for Windows 64" =item versioned_arch( $arch, $version ) Returns $arch, potentially suffixed with a version if $version is at least 5.010. Version 5.010 would be suffixed as "-5.10". Returns undef if $arch is not defined. =back =head1 SEE ALSO L<ppm>, L<ActivePerl::PPM::PPD>, L<Config>
amidoimidazol/bio_info
Beginning Perl for Bioinformatics/lib/ActivePerl/PPM/Arch.pm
Perl
mit
3,958
#!/usr/bin/perl # # ***** BEGIN LICENSE BLOCK ***** # Zimbra Collaboration Suite Server # Copyright (C) 2006, 2007, 2008, 2009, 2010 Zimbra, Inc. # # The contents of this file are subject to the Zimbra Public License # Version 1.3 ("License"); you may not use this file except in # compliance with the License. You may obtain a copy of the License at # http://www.zimbra.com/license. # # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. # ***** END LICENSE BLOCK ***** # use strict; use Migrate; Migrate::verifyLoggerSchemaVersion(3); addLogHostName(); Migrate::updateLoggerSchemaVersion(3,4); exit(0); ##################### sub addLogHostName() { Migrate::log("Adding loghostname"); my $sql = <<EOF; alter table service_status add column loghostname VARCHAR(255) NOT NULL; EOF Migrate::runLoggerSql($sql); }
nico01f/z-pec
ZimbraServer/src/db/migration/migrateLogger4-loghostname.pl
Perl
mit
919
% Prolog Problems - Prolog Lists % http://sites.google.com/site/prologsite/prolog-problems/1 :- module(p1_01, [my_last/2]). :- include('../common'). %% my_last(?LastElement, +List) % % True if LastElement is the last element of List. describe(my_last/2, [ true , fail:my_last(_, []) , my_last(a, [a]) , my_last(b, [a,b]) , my_last(c, [a,b,c]) , my_last(X, [a,b,c]), X == c , one:my_last(_, [a,b,c]) ]). my_last(X, [X]) :- !. my_last(X, [_|Xs]) :- my_last(X, Xs).
khueue/prolog_problems
1_prolog_lists/p1_01.pl
Perl
mit
511
package Paws::ES::DeleteElasticsearchDomain; use Moose; has DomainName => (is => 'ro', isa => 'Str', traits => ['ParamInURI'], uri_name => 'DomainName', required => 1); use MooseX::ClassAttribute; class_has _api_call => (isa => 'Str', is => 'ro', default => 'DeleteElasticsearchDomain'); class_has _api_uri => (isa => 'Str', is => 'ro', default => '/2015-01-01/es/domain/{DomainName}'); class_has _api_method => (isa => 'Str', is => 'ro', default => 'DELETE'); class_has _returns => (isa => 'Str', is => 'ro', default => 'Paws::ES::DeleteElasticsearchDomainResponse'); class_has _result_key => (isa => 'Str', is => 'ro'); 1; ### main pod documentation begin ### =head1 NAME Paws::ES::DeleteElasticsearchDomain - Arguments for method DeleteElasticsearchDomain on Paws::ES =head1 DESCRIPTION This class represents the parameters used for calling the method DeleteElasticsearchDomain on the Amazon Elasticsearch Service service. Use the attributes of this class as arguments to method DeleteElasticsearchDomain. You shouldn't make instances of this class. Each attribute should be used as a named argument in the call to DeleteElasticsearchDomain. As an example: $service_obj->DeleteElasticsearchDomain(Att1 => $value1, Att2 => $value2, ...); Values for attributes that are native types (Int, String, Float, etc) can passed as-is (scalar values). Values for complex Types (objects) can be passed as a HashRef. The keys and values of the hashref will be used to instance the underlying object. =head1 ATTRIBUTES =head2 B<REQUIRED> DomainName => Str The name of the Elasticsearch domain that you want to permanently delete. =head1 SEE ALSO This class forms part of L<Paws>, documenting arguments for method DeleteElasticsearchDomain in L<Paws::ES> =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/ES/DeleteElasticsearchDomain.pm
Perl
apache-2.0
1,962
#!/usr/bin/perl -w # # Copyright 2012, Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # 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. # # This example updates a campaign by setting its status to PAUSED. # To get campaigns, run basic_operations/get_campaigns.pl. # # Tags: CampaignService.mutate # Author: David Torres <api.davidtorres@gmail.com> use strict; use lib "../../../lib"; use Google::Ads::AdWords::Client; use Google::Ads::AdWords::Logging; use Google::Ads::AdWords::v201402::Campaign; use Google::Ads::AdWords::v201402::CampaignOperation; use Cwd qw(abs_path); # Replace with valid values of your account. my $campaign_id = "INSERT_CAMPAIGN_ID_HERE"; # Example main subroutine. sub update_campaign { my $client = shift; my $campaign_id = shift; # Create campaign with updated status. my $campaign = Google::Ads::AdWords::v201402::Campaign->new({ id => $campaign_id, status => "PAUSED" }); # Create operation. my $operation = Google::Ads::AdWords::v201402::CampaignOperation->new({ operand => $campaign, operator => "SET" }); # Update campaign. my $result = $client->CampaignService()->mutate({ operations => [$operation] }); # Display campaigns. if ($result->get_value()) { my $campaign = $result->get_value()->[0]; printf "Campaign with name \"%s\", id \"%d\" and status " . "\"%s\" was updated.\n", $campaign->get_name(), $campaign->get_id(), $campaign->get_status(); } else { print "No campaign was updated.\n"; } return 1; } # Don't run the example if the file is being included. if (abs_path($0) ne abs_path(__FILE__)) { return 1; } # Log SOAP XML request, response and API errors. Google::Ads::AdWords::Logging::enable_all_logging(); # Get AdWords Client, credentials will be read from ~/adwords.properties. my $client = Google::Ads::AdWords::Client->new({version => "v201402"}); # By default examples are set to die on any server returned fault. $client->set_die_on_faults(1); # Call the example update_campaign($client, $campaign_id);
gitpan/GOOGLE-ADWORDS-PERL-CLIENT
examples/v201402/basic_operations/update_campaign.pl
Perl
apache-2.0
2,541
package IrstLMRegressionTesting; use strict; die "*** Cannot find variable IRSTLM in environment ***\n" if !$ENV{IRSTLM}; die "*** Cannot find directory IRSTLM: $ENV{IRSTLM} ***\n" if ! -d $ENV{IRSTLM}; # if your tests need a new version of the test data, increment this # and make sure that a irstlm-regression-tests-vX.Y is available use constant TESTING_DATA_VERSION => '2.0'; # find the data directory in a few likely locations and make sure # that it is the correct version sub find_data_directory { my ($test_script_root, $data_dir) = @_; my $data_version = TESTING_DATA_VERSION; my @ds = (); my $mrtp = "irstlm-reg-test-data-$data_version"; push @ds, $data_dir if defined $data_dir; push @ds, "$test_script_root/$mrtp"; push @ds, "/tmp/$mrtp"; push @ds, "/var/tmp/$mrtp"; foreach my $d (@ds) { print STDERR "d:$d\n"; next unless (-d $d); if (!-d "$d/lm") { print STDERR "Found $d but it is malformed: missing subdir lm/\n"; next; } return $d; } print STDERR<<EOT; You do not appear to have the regression testing data installed. You may either specify a non-standard location (absolute path) when running the test suite with the --data-dir option, or, you may install it in any one of the following standard locations: $test_script_root, /tmp, or /var/tmp with these commands: cd <DESIRED_INSTALLATION_DIRECTORY> tar xzf irstlm-reg-test-data-$data_version.tgz rm irstlm-reg-test-data-$data_version.tgz Please download the archive irstlm-reg-test-data-2.0.tgz from: http://hlt.fbk.eu/en/irstlm EOT exit 1; } 1;
shyamjvs/cs626_project
stat_moses/tools/irstlm-5.80.05/regression-testing/IrstLMRegressionTesting.pm
Perl
apache-2.0
1,593
package Paws::MTurk::GetHIT; use Moose; has HITId => (is => 'ro', isa => 'Str', required => 1); use MooseX::ClassAttribute; class_has _api_call => (isa => 'Str', is => 'ro', default => 'GetHIT'); class_has _returns => (isa => 'Str', is => 'ro', default => 'Paws::MTurk::GetHITResponse'); class_has _result_key => (isa => 'Str', is => 'ro'); 1; ### main pod documentation begin ### =head1 NAME Paws::MTurk::GetHIT - Arguments for method GetHIT on Paws::MTurk =head1 DESCRIPTION This class represents the parameters used for calling the method GetHIT on the Amazon Mechanical Turk service. Use the attributes of this class as arguments to method GetHIT. You shouldn't make instances of this class. Each attribute should be used as a named argument in the call to GetHIT. As an example: $service_obj->GetHIT(Att1 => $value1, Att2 => $value2, ...); Values for attributes that are native types (Int, String, Float, etc) can passed as-is (scalar values). Values for complex Types (objects) can be passed as a HashRef. The keys and values of the hashref will be used to instance the underlying object. =head1 ATTRIBUTES =head2 B<REQUIRED> HITId => Str The ID of the HIT to be retrieved. =head1 SEE ALSO This class forms part of L<Paws>, documenting arguments for method GetHIT in L<Paws::MTurk> =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/MTurk/GetHIT.pm
Perl
apache-2.0
1,501
# # 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 hardware::server::dell::idrac::snmp::mode::components::network; use strict; use warnings; use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status); my $mapping = { networkDeviceStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.90.1.3', map => \%map_status }, networkDeviceProductName => { oid => '.1.3.6.1.4.1.674.10892.5.4.1100.90.1.6' }, }; my $oid_networkDeviceTableEntry = '.1.3.6.1.4.1.674.10892.5.4.1100.90.1'; sub load { my ($self) = @_; push @{$self->{request}}, { oid => $oid_networkDeviceTableEntry }; } sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking networks"); $self->{components}->{network} = {name => 'networks', total => 0, skip => 0}; return if ($self->check_filter(section => 'network')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_networkDeviceTableEntry}})) { next if ($oid !~ /^$mapping->{networkDeviceStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_networkDeviceTableEntry}, instance => $instance); next if ($self->check_filter(section => 'network', instance => $instance)); $self->{components}->{network}->{total}++; $self->{output}->output_add(long_msg => sprintf("network '%s' status is '%s' [instance = %s]", $result->{networkDeviceProductName}, $result->{networkDeviceStatus}, $instance, )); my $exit = $self->get_severity(label => 'default.status', section => 'network.status', value => $result->{networkDeviceStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Network '%s' status is '%s'", $result->{networkDeviceProductName}, $result->{networkDeviceStatus})); } } } 1;
Sims24/centreon-plugins
hardware/server/dell/idrac/snmp/mode/components/network.pm
Perl
apache-2.0
2,835
package Google::Ads::AdWords::v201402::BudgetService::RequestHeader; use strict; use warnings; { # BLOCK to scope variables sub get_xmlns { 'https://adwords.google.com/api/adwords/cm/v201402' } __PACKAGE__->__set_name('RequestHeader'); __PACKAGE__->__set_nillable(); __PACKAGE__->__set_minOccurs(); __PACKAGE__->__set_maxOccurs(); __PACKAGE__->__set_ref(); use base qw( SOAP::WSDL::XSD::Typelib::Element Google::Ads::AdWords::v201402::SoapHeader ); } 1; =pod =head1 NAME Google::Ads::AdWords::v201402::BudgetService::RequestHeader =head1 DESCRIPTION Perl data type class for the XML Schema defined element RequestHeader from the namespace https://adwords.google.com/api/adwords/cm/v201402. =head1 METHODS =head2 new my $element = Google::Ads::AdWords::v201402::BudgetService::RequestHeader->new($data); Constructor. The following data structure may be passed to new(): $a_reference_to, # see Google::Ads::AdWords::v201402::SoapHeader =head1 AUTHOR Generated by SOAP::WSDL =cut
gitpan/GOOGLE-ADWORDS-PERL-CLIENT
lib/Google/Ads/AdWords/v201402/BudgetService/RequestHeader.pm
Perl
apache-2.0
1,014
# # 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 apps::varnish::local::mode::objects; use base qw(centreon::plugins::mode); use centreon::plugins::misc; use centreon::plugins::statefile; use Digest::MD5 qw(md5_hex); my $maps_counters = { n_objsendfile => { thresholds => { warning_objsendfile => { label => 'warning-objsendfile', exit_value => 'warning' }, critical_objsendfile => { label => 'critical-objsendfile', exit_value => 'critical' }, }, output_msg => 'Objects sent with sendfile: %.2f', factor => 1, unit => '', }, n_objwrite => { thresholds => { warning_objwrite => { label => 'warning-objwrite', exit_value => 'warning' }, critical_objwrite => { label => 'critical-objwrite', exit_value => 'critical' }, }, output_msg => 'Objects sent with write: %.2f', factor => 1, unit => '', }, n_objoverflow => { thresholds => { warning_objoverflow => { label => 'warning-objoverflow', exit_value => 'warning' }, critical_objoverflow => { label => 'critical-objoverflow', exit_value => 'critical' }, }, output_msg => 'Objects overflowing workspace: %.2f', factor => 1, unit => '', }, }; 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 => 'varnishstat' }, "command-path:s" => { name => 'command_path', default => '/usr/bin' }, "command-options:s" => { name => 'command_options', default => ' -1 ' }, "command-options2:s" => { name => 'command_options2', default => ' 2>&1' }, }); foreach (keys %{$maps_counters}) { foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { $options{options}->add_options(arguments => { $maps_counters->{$_}->{thresholds}->{$name}->{label} . ':s' => { name => $name }, }); }; }; $self->{instances_done} = {}; $self->{statefile_value} = centreon::plugins::statefile->new(%options); return $self; }; sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); foreach (keys %{$maps_counters}) { foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { if (($self->{perfdata}->threshold_validate(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, value => $self->{option_results}->{$name})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong " . $maps_counters->{$_}->{thresholds}->{$name}->{label} . " threshold '" . $self->{option_results}->{$name} . "'."); $self->{output}->option_exit(); }; }; }; $self->{statefile_value}->check_options(%options); }; sub getdata { 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} . $self->{option_results}->{command_options2}); #print $stdout; foreach (split(/\n/, $stdout)) { #client_conn 7390867 1.00 Client connections # - Symbolic entry name # - Value # - Per-second average over process lifetime, or a period if the value can not be averaged # - Descriptive text if (/^(.\S*)\s*([0-9]*)\s*([0-9.]*)\s(.*)$/i) { #print "FOUND: " . $1 . "=" . $2 . "\n"; $self->{result}->{$1} = $2; }; }; }; sub run { my ($self, %options) = @_; $self->getdata(); $self->{statefile_value}->read(statefile => 'cache_apps_varnish' . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{name}) ? md5_hex($self->{option_results}->{name}) : md5_hex('all'))); $self->{result}->{last_timestamp} = time(); my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp'); # Calculate my $delta_time = $self->{result}->{last_timestamp} - $old_timestamp; $delta_time = 1 if ($delta_time == 0); # One seconds ;) foreach (keys %{$maps_counters}) { #print $_ . "\n"; $self->{old_cache}->{$_} = $self->{statefile_value}->get(name => '$_'); # Get Data from Cache $self->{old_cache}->{$_} = 0 if ( $self->{old_cache}->{$_} > $self->{result}->{$_} ); $self->{outputdata}->{$_} = ($self->{result}->{$_} - $self->{old_cache}->{$_}) / $delta_time; }; # Write Cache if not there $self->{statefile_value}->write(data => $self->{result}); if (!defined($old_timestamp)) { $self->{output}->output_add(severity => 'OK', short_msg => "Buffer creation..."); $self->{output}->display(); $self->{output}->exit(); } my @exits; foreach (keys %{$maps_counters}) { foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { push @exits, $self->{perfdata}->threshold_check(value => $self->{outputdata}->{$_}, threshold => [ { label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, 'exit_litteral' => $maps_counters->{$_}->{thresholds}->{$name}->{exit_value} }]); } } my $exit = $self->{output}->get_most_critical(status => [ @exits ]); my $extra_label = ''; $extra_label = '_' . $instance_output if ($num > 1); my $str_output = ""; my $str_append = ''; foreach (keys %{$maps_counters}) { $str_output .= $str_append . sprintf($maps_counters->{$_}->{output_msg}, $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor}); $str_append = ', '; my ($warning, $critical); foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) { $warning = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'warning'); $critical = $self->{perfdata}->get_perfdata_for_output(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}) if ($maps_counters->{$_}->{thresholds}->{$name}->{exit_value} eq 'critical'); } $self->{output}->perfdata_add(label => $_ . $extra_label, unit => $maps_counters->{$_}->{unit}, value => sprintf("%.2f", $self->{outputdata}->{$_} * $maps_counters->{$_}->{factor}), warning => $warning, critical => $critical); } $self->{output}->output_add(severity => $exit, short_msg => $str_output); $self->{output}->display(); $self->{output}->exit(); }; 1; __END__ =head1 MODE Check Varnish Cache with varnishstat Command =over 8 =item B<--remote> If you dont run this script locally, if you wanna use it remote, you can run it remotely with '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<--command> Varnishstat Binary Filename (Default: varnishstat) =item B<--command-path> Directory Path to Varnishstat Binary File (Default: /usr/bin) =item B<--command-options> Parameter for Binary File (Default: ' -1 ') =item B<--warning-*> Warning Threshold for: objsendfile => Objects sent with sendfile, objwrite => Objects sent with write, objoverflow => Objects overflowing workspace =item B<--critical-*> Critical Threshold for: objsendfile => Objects sent with sendfile, objwrite => Objects sent with write, objoverflow => Objects overflowing workspace =back =cut
wilfriedcomte/centreon-plugins
apps/varnish/local/mode/objects.pm
Perl
apache-2.0
9,671
=head1 LICENSE Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Copyright [2016-2021] EMBL-European Bioinformatics Institute Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =cut package EnsEMBL::Web::Ticket::AlleleFrequency; use strict; use warnings; use List::Util qw(first); use EnsEMBL::Web::Exceptions; use EnsEMBL::Web::Job::AlleleFrequency; use parent qw(EnsEMBL::Web::Ticket); sub init_from_user_input { ## Abstract method implementation my $self = shift; my $hub = $self->hub; my $species = $hub->param('species'); my $region = uc($hub->param('region') // '') =~ s/[^A-Z0-9_\:\-]//gr; # remove unwanted chars (eg. spaces and commas) throw exception('InputError', sprintf('Invalid region "%s"', $region)) unless $region =~ /^[A-Z0-9_\-]+\:\d+\-\d+$/; my ($fix_sample_url, $population); if($hub->param('collection_format') eq 'phase1') { $fix_sample_url = $SiteDefs::PHASE1_PANEL_URL; $population = "phase1_populations"; } elsif ($hub->param('collection_format') eq 'phase3') { $fix_sample_url = $region =~ /^Y:/g ? $SiteDefs::PHASE3_MALE_URL : $SiteDefs::PHASE3_PANEL_URL; $population = $region =~ /^Y:/g ? "phase3_male_populations" : "phase3_populations"; } else { $population = "custom_populations"; } throw exception('InputError', 'No input data is present') unless $hub->param('custom_file_url') || $hub->param('generated_file_url'); $self->add_job(EnsEMBL::Web::Job::AlleleFrequency->new($self, { 'job_desc' => $hub->param('name') ? $hub->param('name') : $hub->param('collection_format') eq 'custom' ? "Allele frequency (Custom file)" : "Allele frequency (".$hub->param('collection_format').")", 'species' => $species, 'assembly' => $hub->species_defs->get_config($species, 'ASSEMBLY_VERSION'), 'job_data' => { 'species' => $species, 'job_desc' => $hub->param('name') ? $hub->param('name') : $hub->param('collection_format') eq 'custom' ? "Allele frequency (Custom file)" : "Allele frequency (".$hub->param('collection_format').")", 'upload_type' => $hub->param('collection_format'), 'file_url' => $hub->param('custom_file_url') ? $hub->param('custom_file_url') : $hub->param('generated_file_url'), 'sample_panel' => $hub->param('custom_sample_url') ? $hub->param('custom_sample_url') : $fix_sample_url, 'region' => $region, 'population' => $hub->param($population) ? join(',',$hub->param($population)) : 'ALL', } })); } 1;
Ensembl/public-plugins
tools/modules/EnsEMBL/Web/Ticket/AlleleFrequency.pm
Perl
apache-2.0
3,069
package Google::Ads::AdWords::v201402::BiddableAdGroupCriterionExperimentData; use strict; use warnings; __PACKAGE__->_set_element_form_qualified(1); sub get_xmlns { 'https://adwords.google.com/api/adwords/cm/v201402' }; our $XML_ATTRIBUTE_CLASS; undef $XML_ATTRIBUTE_CLASS; sub __get_attr_class { return $XML_ATTRIBUTE_CLASS; } use Class::Std::Fast::Storable constructor => 'none'; use base qw(Google::Ads::SOAP::Typelib::ComplexType); { # BLOCK to scope variables my %experimentId_of :ATTR(:get<experimentId>); my %experimentDeltaStatus_of :ATTR(:get<experimentDeltaStatus>); my %experimentDataStatus_of :ATTR(:get<experimentDataStatus>); my %experimentBidMultiplier_of :ATTR(:get<experimentBidMultiplier>); __PACKAGE__->_factory( [ qw( experimentId experimentDeltaStatus experimentDataStatus experimentBidMultiplier ) ], { 'experimentId' => \%experimentId_of, 'experimentDeltaStatus' => \%experimentDeltaStatus_of, 'experimentDataStatus' => \%experimentDataStatus_of, 'experimentBidMultiplier' => \%experimentBidMultiplier_of, }, { 'experimentId' => 'SOAP::WSDL::XSD::Typelib::Builtin::long', 'experimentDeltaStatus' => 'Google::Ads::AdWords::v201402::ExperimentDeltaStatus', 'experimentDataStatus' => 'Google::Ads::AdWords::v201402::ExperimentDataStatus', 'experimentBidMultiplier' => 'Google::Ads::AdWords::v201402::AdGroupCriterionExperimentBidMultiplier', }, { 'experimentId' => 'experimentId', 'experimentDeltaStatus' => 'experimentDeltaStatus', 'experimentDataStatus' => 'experimentDataStatus', 'experimentBidMultiplier' => 'experimentBidMultiplier', } ); } # end BLOCK 1; =pod =head1 NAME Google::Ads::AdWords::v201402::BiddableAdGroupCriterionExperimentData =head1 DESCRIPTION Perl data type class for the XML Schema defined complexType BiddableAdGroupCriterionExperimentData from the namespace https://adwords.google.com/api/adwords/cm/v201402. Data associated with an advertiser experiment for this {@link BiddableAdGroupCriterion}. =head2 PROPERTIES The following properties may be accessed using get_PROPERTY / set_PROPERTY methods: =over =item * experimentId =item * experimentDeltaStatus =item * experimentDataStatus =item * experimentBidMultiplier =back =head1 METHODS =head2 new Constructor. The following data structure may be passed to new(): =head1 AUTHOR Generated by SOAP::WSDL =cut
gitpan/GOOGLE-ADWORDS-PERL-CLIENT
lib/Google/Ads/AdWords/v201402/BiddableAdGroupCriterionExperimentData.pm
Perl
apache-2.0
2,527
=pod =head1 NAME Bio::EnsEMBL::Hive::DBSQL::PipelineWideParametersAdaptor =head1 SYNOPSIS $pipeline_wide_parameters_adaptor = $db_adaptor->get_PipelineWideParametersAdaptor; =head1 DESCRIPTION This module deals with pipeline_wide_parameters' storage and retrieval, and also stores 'schema_version' for compatibility with Core API =head1 LICENSE Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Copyright [2016-2022] 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 subscribe to the Hive mailing list: http://listserver.ebi.ac.uk/mailman/listinfo/ehive-users to discuss Hive-related questions or to be notified of our updates =cut package Bio::EnsEMBL::Hive::DBSQL::PipelineWideParametersAdaptor; use strict; use warnings; use base ('Bio::EnsEMBL::Hive::DBSQL::NakedTableAdaptor'); sub default_table_name { return 'pipeline_wide_parameters'; } 1;
Ensembl/ensembl-hive
modules/Bio/EnsEMBL/Hive/DBSQL/PipelineWideParametersAdaptor.pm
Perl
apache-2.0
1,509
package Paws::Kinesis::EnhancedMonitoringOutput; use Moose; has CurrentShardLevelMetrics => (is => 'ro', isa => 'ArrayRef[Str|Undef]'); has DesiredShardLevelMetrics => (is => 'ro', isa => 'ArrayRef[Str|Undef]'); has StreamName => (is => 'ro', isa => 'Str'); has _request_id => (is => 'ro', isa => 'Str'); ### main pod documentation begin ### =head1 NAME Paws::Kinesis::EnhancedMonitoringOutput =head1 ATTRIBUTES =head2 CurrentShardLevelMetrics => ArrayRef[Str|Undef] Represents the current state of the metrics that are in the enhanced state before the operation. =head2 DesiredShardLevelMetrics => ArrayRef[Str|Undef] Represents the list of all the metrics that would be in the enhanced state after the operation. =head2 StreamName => Str The name of the Amazon Kinesis stream. =head2 _request_id => Str =cut 1;
ioanrogers/aws-sdk-perl
auto-lib/Paws/Kinesis/EnhancedMonitoringOutput.pm
Perl
apache-2.0
842
=head1 NAME LedgerSMB::Report::Axis - Models axes of financial reports =head1 SYNPOSIS my $axis = LedgerSMB::Report::Axis->new(); my $id = $axis->map_path(['head1','head2','head3','acc']); my $axis_ids = $axis->sort(); =head1 DESCRIPTION This module provides a mapping of (hierarchical) account reporting to a flat axis as required for generation of the table that makes up the final report. =cut package LedgerSMB::Report::Axis; use Moose; =head1 PROPERTIES =over =item tree Read-only accessor, a hash of hashes, keyed on the "account number". E.g.: { 'head1' => { id => 1, accno => 'head1', path => [ 'head1' ], section => { id => 2, props => { section_for => 1 } }, children => { 'head2' => { id => 3, accno => 'head2', path => [ 'head1', 'head2' ], children => {}, parent_id => 1 } } } } =cut has 'tree' => ( is => 'ro', default => sub { {} }, isa => 'HashRef' ); =item ids Read-only accessor; a list of IDs of axis elements, including section heads. To skip section heads, skip IDs for which a props key 'section_for' exists. =cut has 'ids' => ( is => 'ro', default => sub { {} }, isa => 'HashRef' ); has '_last_id' => ( is => 'rw', default => 0, isa => 'Int' ); =back =head1 METHODS =over =item map_path() Maps a given path to an axis ID =cut sub map_path { my ($self, $path) = @_; my $subtree = $self->tree; my $elem; my $this_path = []; for my $step (@$path) { push @$this_path, $step; $self->_new_elem($subtree, $step, $this_path, $elem) if ! exists $subtree->{$step}; $elem = $subtree->{$step}; $subtree = $subtree->{$step}->{children}; } return $elem->{id}; } sub _new_elem { my ($self, $subtree, $step, $path, $parent) = @_; $subtree->{$step} = { id => $self->_last_id($self->_last_id + 1), accno => $step, path => [ (@$path) ], children => {}, parent_id => $parent->{id}, }; $self->ids->{$subtree->{$step}->{id}} = $subtree->{$step}; my $section = { id => $self->_last_id($self->_last_id + 1), path => [ (@$path) ], props => { section_for => $subtree->{$step}->{id}, }, }; $self->ids->{$section->{id}} = $section; $subtree->{$step}->{section} = $section; return $subtree->{$step}; } =item sort Returns an array reference with axis IDs, alphabetically sorted by the elements in the path (usually header and account numbers), unless the 'order' property is defined, in which case that's used. =cut sub sort { my ($self) = @_; return _sort_aux($self->tree); } sub _sort_aux { my ($subtree) = @_; my @sorted; my $cmpv = sub { return ((defined $subtree->{$_[0]}->{props} && $subtree->{$_[0]}->{props}->{order}) || $_[0]); }; for (sort { &$cmpv($a) cmp &$cmpv($b) } keys %$subtree) { push @sorted, $subtree->{$_}->{section}->{id} if scalar(keys %{$subtree->{$_}->{children}}) > 0; push @sorted, @{_sort_aux($subtree->{$_}->{children})}; push @sorted, $subtree->{$_}->{id}; } return \@sorted; } =item $self->id_props($id, [\@props]) Returns the properties registered for the given ID. If an array reference is provided as the second parameter, that value is used to set the ID's properties. =cut sub id_props { my ($self, $id, $props) = @_; $self->ids->{$id}->{props} = $props if defined $props; return $self->ids->{$id}->{props}; } =back =head1 COPYRIGHT COPYRIGHT (C) 2015 The LedgerSMB Core Team. This file may be re-used following the terms of the GNU General Public License version 2 or at your option any later version. Please see included LICENSE.TXT for details. =cut __PACKAGE__->meta->make_immutable; 1;
tridentcodesolution/tridentcodesolution.github.io
projects/CRM/LedgerSMB-master/LedgerSMB/Report/Axis.pm
Perl
apache-2.0
4,271
:- module(agent2,[agent2/2],[persdb]). :- use_module(send, [send/2]). :- use_module(library(numlists),[ sum_list/2 ]). persistent_dir(trace_db,traces). :- persistent(received/2, trace_db). agent2(Sender, Msg) :- assertz_fact(received(Sender, Msg)), case(Msg, Sender). case(shutdown, _) :- !, halt. case(add(NumList), Sender) :- sum_list(NumList, Sum), send(Sender, sum(Sum)), !. case(_, _).
leuschel/ecce
www/CiaoDE/ciao/library/actmods/examples/agents/agent2.pl
Perl
apache-2.0
419
# # 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. # # Copyright (c) 2016,2019 by Delphix. All rights reserved. # # Program Name : dx_set_envpass.pl # Description : Set password for OS Delphix user or DB Delphix user # Author : Marcin Przepiorowski # Created : 29 Apr 2016 (v2.2.5) # # use strict; use warnings; use JSON; use Getopt::Long qw(:config no_ignore_case no_auto_abbrev); #avoids conflicts with ex host and help use File::Basename; use Pod::Usage; use FindBin; use Data::Dumper; my $abspath = $FindBin::Bin; use lib '../lib'; use Engine; use Formater; use Environment_obj; use Toolkit_helpers; use Host_obj; use Action_obj; my $version = $Toolkit_helpers::version; GetOptions( 'help|?' => \(my $help), 'd|engine=s' => \(my $dx_host), 'envname=s' => \(my $envname), 'username=s' => \(my $username), 'password=s' => \(my $password), 'debug:i' => \(my $debug), 'dever=s' => \(my $dever), 'all' => (\my $all), 'version' => \(my $print_version), 'configfile|c=s' => \(my $config_file) ) or pod2usage(-verbose => 1, -input=>\*DATA); pod2usage(-verbose => 2, -input=>\*DATA) && exit if $help; die "$version\n" if $print_version; my $engine_obj = new Engine ($dever, $debug); $engine_obj->load_config($config_file); if (defined($all) && defined($dx_host)) { print "Option all (-all) and engine (-d|engine) are mutually exclusive \n"; pod2usage(-verbose => 1, -input=>\*DATA); exit (1); } if (! (defined($username) && defined($password) ) ) { print "Option username and password are required. \n"; pod2usage(-verbose => 1, -input=>\*DATA); exit (1); } # this array will have all engines to go through (if -d is specified it will be only one engine) my $engine_list = Toolkit_helpers::get_engine_list($all, $dx_host, $engine_obj); my %restore_state; my $ret = 0; for my $engine ( sort (@{$engine_list}) ) { # main loop for all work if ($engine_obj->dlpx_connect($engine)) { print "Can't connect to Dephix Engine $dx_host\n\n"; $ret = $ret + 1; next; }; # load objects for current engine my $environments = new Environment_obj( $engine_obj, $debug); my $hosts = new Host_obj ( $engine_obj, $debug ); # filter implementation my @env_list; if (defined($envname)) { push(@env_list, $environments->getEnvironmentByName($envname)->{reference}); } else { @env_list = $environments->getAllEnvironments(); }; # for filtered databases on current engine - display status for my $envitem ( @env_list ) { my $env_user = $environments->getEnvironmentUserByName($envitem, $username); my $envname = $environments->getName($envitem); if (!defined($env_user)) { print "User $username not found in environment $envname . \n"; next; } my $hostref = $environments->getHost($envitem); my $connfault = 0; my $result; if ( $environments->getType($envitem) ne 'windows' ) { # check ssh connectivity if ( $hostref eq 'CLUSTER' ) { my $cluhosts = $environments->getOracleClusterNode($envitem); for my $clunode ( @{$cluhosts} ) { my $nodeaddr = $hosts->getHostAddr($clunode->{host}); my $port = $hosts->getHostPort($clunode->{host}); ($connfault, $result) = $connfault + $engine_obj->checkSSHconnectivity($username, $password, $nodeaddr, $port); } } else { my $nodeaddr = $hosts->getHostAddr($hostref); my $port = $hosts->getHostPort($hostref); ($connfault, $result) = $engine_obj->checkSSHconnectivity($username, $password, $nodeaddr, $port); } } else { if ( $hostref ne 'CLUSTER' ) { my $nodeaddr = $hosts->getHostAddr($hostref); ($connfault, $result) = $engine_obj->checkConnectorconnectivity($username, $password, $nodeaddr); } } my $jobno; if ($connfault) { print "Error. Provided credentials doesn't work for environment $envname.\n"; $ret = $ret + 1; } else { $jobno = $environments->changePassword($env_user, $password); } $ret = $ret + Toolkit_helpers::waitForAction($engine_obj, $jobno, "Password change actions is completed with success for environment $envname.", "There were problems with changing password."); } } exit $ret; __DATA__ =head1 SYNOPSIS dx_set_envpass [ -engine|d <delphix identifier> | -all ] [ -configfile file ][ -envname env_name ] -username <username> -password <password> [ --help|? ] [ -debug ] =head1 DESCRIPTION Change user password for an environment =head1 ARGUMENTS Delphix Engine selection - if not specified a default host(s) from dxtools.conf will be used. =over 10 =item B<-engine|d> Specify Delphix Engine name from dxtools.conf file =item B<-all> Run script on all engines =item B<-envname name> Specify an environment name =item B<-username user> Specify a user =item B<-password pass> Specify a password =back =head1 OPTIONS =over 2 =item B<-help> Print this screen =item B<-debug> Turn on debugging =back =head1 EXAMPLES Set a new environment password for environment LINUXSOURCE dx_set_envpass -d Landshark5 -envname LINUXSOURCE -username delphix -password delphix Waiting for all actions to complete. Parent action is ACTION-5877 Password change actions is completed with success for environment LINUXSOURCE. =cut
delphix/dxtoolkit
bin/dx_set_envpass.pl
Perl
apache-2.0
5,826
# @file: Config.pm # @brief: # @author: YoungJoo.Kim <vozlt@vozlt.com> # @version: # @date: package Deploy::Config; use strict; use Deploy::File; our(@ISA); @ISA = qw(Deploy::File); sub new{ my($class, %cnf) = @_; my $debug = delete $cnf{debug}; my $warn = delete $cnf{warn}; $debug = 0 unless defined $debug; $warn = 0 unless defined $warn; my $self = bless { debug => $debug, warn => $warn, process_id => $$ }, $class; return bless $self; } sub parseIniFile { my $self = shift if ref ($_[0]); my $path = shift; my @arg = (); my %cnf = (); my $key = undef; for(my @lines = $self->fileReadLines($path)) { chomp; s/^\s+//; s/\s+$//; s/^[#;].*//; next unless length; # Only two args @arg = split(/\s*[=]\s*/, $_, 2); if ($#arg == 0) { $key = $arg[0]; $key =~ s/(^\[|\]$)//g; } if ($#arg == 1) { if ($arg[0] =~ /\[\]$/) { my $two = $arg[0]; $two =~ s/\[\]$//; push(@{$cnf{$key}{$two}}, $arg[1]); } else { $key = 'list' unless defined($key); if ($key) { $cnf{$key}{$arg[0]} = $arg[1]; } else { $cnf{$arg[0]} = $arg[1]; } } } } return %cnf; } sub DESTROY { my $self = shift if ref ($_[0]); # thread safe ($$ != $self->{process_id}) && return; for my $class (@ISA) { my $destroy = $class . "::DESTROY"; $self->$destroy if $self->can($destroy); } } 1; # vi:set ft=perl ts=4 sw=4 et fdm=marker:
vozlt/deploy
src/lib/Deploy/Config.pm
Perl
bsd-2-clause
1,754
# Copyright (c)2000-2013, Chris Pressey, Cat's Eye Technologies. # All rights reserved. # Distributed under a BSD-style license; see file LICENSE for more info. package Distribution; ### DISTRIBUTIONS ### $even_sex = Distribution->new(0.50 => 'Male', 0.50 => 'Female'); $hive_sex = Distribution->new(0.25 => 'Male', 0.75 => 'Female'); $humanoid_hand_dominance = Distribution->new(0.60 => 'rhand', 0.35 => 'lhand', 0.05 => 'ambi'); $humanoid_hair_type = Distribution->new( 0.10 => 'balding', 0.10 => 'greasy', 0.15 => 'frazzled', 0.15 => 'curly', 0.25 => 'wavy', 0.25 => 'straight', ); $humanoid_hair_color = Distribution->new( 0.10 => 'blonde', 0.15 => 'red', 0.20 => 'auburn', 0.25 => 'black', 0.30 => 'brown', ); $humanoid_eye_type = Distribution->new( 0.1 => 'piercing', 0.1 => 'glassy', 0.1 => 'squinting', 0.1 => 'soft', 0.1 => 'cold', 0.1 => 'icy', 0.1 => 'serious', 0.1 => 'shifty', 0.1 => 'laughing', 0.1 => 'warm', ); $humanoid_eye_color = Distribution->new( 0.10 => 'grey', 0.15 => 'blue', 0.20 => 'almond', 0.25 => 'green', 0.30 => 'brown', ); $humanoid_skin_type = Distribution->new( 0.05 => 'oily', 0.10 => 'fine', 0.15 => 'blotchy', 0.20 => 'fair', 0.25 => 'smooth', 0.25 => 'rough', ); $humanoid_skin_color = Distribution->new( 0.20 => 'brown', 0.20 => 'grey', 0.20 => 'pink', 0.20 => 'yellow', 0.20 => 'red', ); ### BODY PART ATTACK DISTRIBUTIONS ### %bp = ( 'dumb_biped' => Distribution->new(0.35 => 'torso', 0.15 => 'arms', 0.10 => 'shoulders', 0.10 => 'head', 0.10 => 'legs', 0.10 => 'hands', 0.05 => 'waist', 0.05 => 'feet'), 'smart_biped' => Distribution->new(0.30 => 'head', 0.15 => 'torso', 0.10 => 'waist', 0.10 => 'legs', 0.10 => 'hands', 0.10 => 'feet', 0.07 => 'shoulders', 0.08 => 'arms'), 'random' => Distribution->new(0.125 => 'torso', 0.125 => 'legs', 0.125 => 'shoulders', 0.125 => 'arms', 0.125 => 'waist', 0.125 => 'hands', 0.125 => 'head', 0.125 => 'feet'), 'pouncer' => Distribution->new(0.25 => 'torso', 0.20 => 'hands', 0.15 => 'head', 0.10 => 'shoulders', 0.10 => 'waist', 0.08 => 'arms', 0.07 => 'legs', 0.05 => 'feet'), 'creepy_crawly' => Distribution->new(0.60 => 'feet', 0.15 => 'legs', 0.15 => 'hands', 0.10 => 'arms'), 'small_winged' => Distribution->new(0.35 => 'head', 0.15 => 'shoulders', 0.25 => 'arms', 0.25 => 'hands'), ); 1;
catseye/Corona-Realm-of-Magic
src/corona/Distributions.pm
Perl
bsd-3-clause
5,432
#!/usr/bin/perl print "Task Lister\n"; print "Until we have \"ps\", we might as well have this.\n"; print "\n"; if (scalar(@ARGV) == 0) { print "usage: taskCount.pl <platform>"; exit; } $platform = $ARGV[0]; open(APP, "build/$platform/app.c") or die "Failed to open build/$platform/app.c"; open(EXE, "objdump -x build/$platform/main.exe |") or die "Failed to run objdump build/$platform/main.exe"; foreach $line (<APP>) { if ($line =~ /TOS_post/ && !($line =~ /void/)) { # print $line; $line =~ s/^.*TOS_post\((.*?)\).*/$1/; chomp($line); $tasks{$line} = 1; } } foreach $line (<EXE>) { if ( $line =~ /^(\S+).+? \.text\s+\S+ (\S+)/ ) { # print $line; ($addr, $symbol) = ($1, $2); $symtab{$symbol} = hex $addr; # print "$addr $symbol\n"; } } print "Addr\tName\n"; foreach $task (sort keys %tasks) { $dotTask = $task; $dotTask =~ s/\$/./; printf("0x%x\t%s\n", $symtab{$task}, $dotTask); $taskCount++; } print "\n$taskCount tasks\n";
ekiwi/tinyos-1.x
contrib/boomerang/tinyos-1.x/tools/scripts/taskCount.pl
Perl
bsd-3-clause
985
#!/usr/bin/env perl # ==================================================================== # Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL # project. The module is, however, dual licensed under OpenSSL and # CRYPTOGAMS licenses depending on where you obtain it. For further # details see http://www.openssl.org/~appro/cryptogams/. # ==================================================================== # 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 key lengthes 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. $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"; 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.=<<___; stmg %r3,$ra,24($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 lg $out,24($sp) st $s0,0($out) st $s1,4($out) st $s2,8($out) st $s3,12($out) lmg %r6,$ra,48($sp) br $ra .size AES_encrypt,.-AES_encrypt .type _s390x_AES_encrypt,\@function .align 16 _s390x_AES_encrypt: stg $ra,152($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 lg $ra,152($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.=<<___; stmg %r3,$ra,24($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 lg $out,24($sp) st $s0,0($out) st $s1,4($out) st $s2,8($out) st $s3,12($out) lmg %r6,$ra,48($sp) br $ra .size AES_decrypt,.-AES_decrypt .type _s390x_AES_decrypt,\@function .align 16 _s390x_AES_decrypt: stg $ra,152($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 lg $ra,152($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: lghi $t0,0 clgr $inp,$t0 je .Lminus1 clgr $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 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 lg %r0,0(%r1) tmhl %r0,0x4000 # check for message-security assist jz .Lekey_internal lghi %r0,0 # query capability vector la %r1,16($sp) .long 0xb92f0042 # kmc %r4,%r2 llihh %r1,0x8000 srlg %r1,%r1,0(%r5) ng %r1,16($sp) 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 st %r5,240($key) # save km code lghi %r2,0 br %r14 ___ $code.=<<___; .align 16 .Lekey_internal: stmg %r6,%r13,48($sp) # all non-volatile regs 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 %r2,0 lmg %r6,%r13,48($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 %r2,0 lmg %r6,%r13,48($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 %r2,0 lmg %r6,%r13,48($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: stg $key,32($sp) # I rely on AES_set_encrypt_key to stg $ra,112($sp) # save non-volatile registers! bras $ra,AES_set_encrypt_key lg $key,32($sp) lg $ra,112($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 .align 16 .Ldkey_internal: stg $key,32($sp) stg $ra,40($sp) bras $ra,.Lekey_internal lg $key,32($sp) lg $ra,40($sp) ___ $code.=<<___; .Lgo: 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 lmg %r6,%r13,48($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 slgr $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,128($sp) stg %r1,136($sp) bras %r1,1f mvc 128(1,$sp),0($inp) 1: ex $key,0(%r1) la %r1,16($sp) # restore parameter block la $inp,128($sp) lghi $len,16 .long 0xb92f0042 # kmc %r4,%r2 j .Lkmc_done .align 16 .Lkmc_truncated_dec: stg $out,64($sp) la $out,128($sp) lghi $len,16 .long 0xb92f0042 # kmc %r4,%r2 lg $out,64($sp) bras %r1,2f mvc 0(1,$out),128($sp) 2: ex $key,0(%r1) j .Lkmc_done .align 16 .Lcbc_software: ___ $code.=<<___; stmg $key,$ra,40($sp) lhi %r0,0 cl %r0,164($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 slgr $len,$t0 brc 4,.Lcbc_enc_tail # if borrow .Lcbc_enc_loop: stmg $inp,$out,16($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 lmg $inp,$key,16($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 ltgr $len,$len jz .Lcbc_enc_done slgr $len,$t0 brc 4,.Lcbc_enc_tail # if borrow j .Lcbc_enc_loop .align 16 .Lcbc_enc_done: lg $ivp,48($sp) st $s0,0($ivp) st $s1,4($ivp) st $s2,8($ivp) st $s3,12($ivp) lmg %r7,$ra,56($sp) br $ra .align 16 .Lcbc_enc_tail: aghi $len,15 lghi $t0,0 stg $t0,128($sp) stg $t0,136($sp) bras $t1,3f mvc 128(1,$sp),0($inp) 3: ex $len,0($t1) lghi $len,0 la $inp,128($sp) j .Lcbc_enc_loop .align 16 .Lcbc_decrypt: larl $tbl,AES_Td lg $t0,0($ivp) lg $t1,8($ivp) stmg $t0,$t1,128($sp) .Lcbc_dec_loop: stmg $inp,$out,16($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 lmg $inp,$key,16($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,128($sp) xg $s2,136($sp) lghi $s1,16 slgr $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,128($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: lmg $ivp,$ra,48($sp) stmg $t0,$t1,0($ivp) br $ra .align 16 .Lcbc_dec_tail: aghi $len,15 stg $s0,128($sp) stg $s2,136($sp) bras $s1,4f mvc 0(1,$out),128($sp) 4: ex $len,0($s1) j .Lcbc_dec_exit .size AES_cbc_encrypt,.-AES_cbc_encrypt .comm OPENSSL_s390xcap_P,8,8 ___ } $code.=<<___; .string "AES for s390x, CRYPTOGAMS by <appro\@openssl.org>" ___ $code =~ s/\`([^\`]*)\`/eval $1/gem; print $code;
jiangzhu1212/oooii
Ouroboros/External/OpenSSL/openssl-1.0.0e/crypto/aes/asm/aes-s390x.pl
Perl
mit
32,892
<?php $HERE_INITIALIZATION_TAKE_PLACE = 'Tutaj inicjalizujesz moduł [app::$user].'; // Timeout $TIMEOUT_IS_OKEY = 'Czas bezczynności ustawiony prawidłowo.'; $FORGET_PASS_TIMEOUT = 'Zapomniałeś ustawić czasu bezczynności.'; $PASSED_TIMEOUT_REFERENCE_IS_WRONG = 'Zła konfiguracja.'; // Refresh $REFRESH_IS_OKEY = 'Czas odświeżania sesji jest okey.'; $FORGET_PASS_REFRESH = 'Zapomniałeś ustawić czas odświeżania.'; $PASSED_REFRESH_REFERENCE_IS_WRONG = 'Zła wartość.'; // User $USER_REFERENCE_IS_OKEY = 'Referencja do tablicy #user# jest okey.'; $FORGET_PASS_USER_TABLE = 'Brakuje referencji do tablicy #user#.'; $PASSED_USER_TABLE_REFERENCE_IS_WRONG = 'Referencja do tablicy #user# jest zła.'; // Token $TOKEN_REFERENCE_IS_OKEY = 'Referencja do tablicy #token# jest okey.'; $FORGET_PASS_TOKEN_TABLE = 'Zapomniałeś przekazać referencje do tablicy #token#.'; $PASSED_TOKEN_TABLE_REFERENCE_IS_WRONG = 'Ta referencja jest zła, nie wskazuje na tablicę #token#.'; // User_Token $USERTOKEN_REFERENCE_IS_OKEY = 'Referencja do tablicy #user_token# jest okey.'; $FORGET_PASS_USERTOKEN_TABLE = 'Zapomniałeś o referencji do #user_token#.'; $PASSED_USERTOKEN_TABLE_REFERENCE_IS_WRONG = 'To nie jest referencja do tablicy #user_token#.'; // Request $REQUEST_REFERENCE_IS_OKEY = 'Moduł [app::$request] jest okey.'; $FORGET_PASS_REQUEST = 'Zapomniałeś przekazać referencji do [app::$request].'; $PASSED_REQUEST_REFERENCE_IS_WRONG = 'Przekazana referencja nie wskazuje na [app::$request].'; // Session $SESSION_REFERENCE_IS_OKEY = 'Moduł [app::$session] jest okey.'; $FORGET_PASS_SESSION = 'Zapomniałeś przekazać referencji do [app::$session].'; $PASSED_SESSION_REFERENCE_IS_WRONG = 'Przekazana referencja jest nieprawidłowa.'; // Account $ACCOUNT_REFERENCE_IS_OKEY = 'Zmienna [app::$account] jest okey.';
deArcane/framework
src/User28/_Exception/Init/CommonUserInit.lang.pl
Perl
mit
1,832
package Google::Ads::AdWords::v201406::AdGroupCriterionLabelReturnValue; use strict; use warnings; __PACKAGE__->_set_element_form_qualified(1); sub get_xmlns { 'https://adwords.google.com/api/adwords/cm/v201406' }; our $XML_ATTRIBUTE_CLASS; undef $XML_ATTRIBUTE_CLASS; sub __get_attr_class { return $XML_ATTRIBUTE_CLASS; } use base qw(Google::Ads::AdWords::v201406::ListReturnValue); # Variety: sequence use Class::Std::Fast::Storable constructor => 'none'; use base qw(Google::Ads::SOAP::Typelib::ComplexType); { # BLOCK to scope variables my %ListReturnValue__Type_of :ATTR(:get<ListReturnValue__Type>); my %value_of :ATTR(:get<value>); my %partialFailureErrors_of :ATTR(:get<partialFailureErrors>); __PACKAGE__->_factory( [ qw( ListReturnValue__Type value partialFailureErrors ) ], { 'ListReturnValue__Type' => \%ListReturnValue__Type_of, 'value' => \%value_of, 'partialFailureErrors' => \%partialFailureErrors_of, }, { 'ListReturnValue__Type' => 'SOAP::WSDL::XSD::Typelib::Builtin::string', 'value' => 'Google::Ads::AdWords::v201406::AdGroupCriterionLabel', 'partialFailureErrors' => 'Google::Ads::AdWords::v201406::ApiError', }, { 'ListReturnValue__Type' => 'ListReturnValue.Type', 'value' => 'value', 'partialFailureErrors' => 'partialFailureErrors', } ); } # end BLOCK 1; =pod =head1 NAME Google::Ads::AdWords::v201406::AdGroupCriterionLabelReturnValue =head1 DESCRIPTION Perl data type class for the XML Schema defined complexType AdGroupCriterionLabelReturnValue from the namespace https://adwords.google.com/api/adwords/cm/v201406. A container for return values from the {@link AdGroupCriterionService#mutateLabel} call. =head2 PROPERTIES The following properties may be accessed using get_PROPERTY / set_PROPERTY methods: =over =item * value =item * partialFailureErrors =back =head1 METHODS =head2 new Constructor. The following data structure may be passed to new(): =head1 AUTHOR Generated by SOAP::WSDL =cut
gitpan/GOOGLE-ADWORDS-PERL-CLIENT
lib/Google/Ads/AdWords/v201406/AdGroupCriterionLabelReturnValue.pm
Perl
apache-2.0
2,108
# -*- perl -*- use strict; use CoGeX; my $connstr = 'dbi:mysql:dbname=DB;host=HOST;port=PORT'; my $s = CoGeX->connect($connstr, 'USER', 'PASSWORD' ); # example for getting 10,000-mer chunks. my $dataset = [565]; get_10kmers( 'sorghum', $dataset ); # example for getting accns from a file: # only gets OS01G12345, not OS01G12345.1 # gets the CDS if available, else gene else *RNA, psuedogene # prints to an output file $org.fasta. # needs a file named $org_accns.txt which is a list of accn names. # can be made with an sql query like: # SELECT DISTINCT(fn.name) from feature_name fn, feature f where # fn.feature_id = f.feature_id AND f.dataset_id BETWEEN 582 AND 593 AND # fn.name LIKE 'Os%%g%' AND fn.name NOT LIKE '%.%' ORDER BY fn.name; my $name_re = '^OS(\d\d)G\d{5}$'; my $name_len = 10; my $org = 'rice'; my @datasets = 582 .. 593; get_accn_locs( $name_re, $name_len, $org, \@datasets ); sub get_accn_locs { my ( $name_re, $name_len, $org, $datasets ) = @_; my %seen; my %order; open( ACCN, "<", $org . "_accns.txt" ) or die "must have a list of accns in $org" . "_accns.txt"; open( LOC, ">", $org . ".fasta" ); while ( my $accn = <ACCN> ) { chomp $accn; next unless $accn =~ /$name_re/i; foreach my $feat ( $s->resultset('Feature')->search( { 'feature_names.name' => $accn, 'me.dataset_id' => { 'IN' => $datasets } }, { prefetch => [ 'feature_names', 'feature_type' ], order_by => ['feature_type.name'] } ) ) { my @feat_names = map { $_->name } $feat->feature_names(); if ( scalar( grep { $seen{ substr( uc($_), 0, $name_len ) } } @feat_names ) ) { next; } my @names = sort grep { $_ =~ /$name_re/i } @feat_names; my $name = uc( @names[0] ); if ( !$name ) { @names = sort grep { $_ =~ /$name_re/i } @feat_names; $name = @names[0]; # . "|" . $feat->feature_id; if ( !$name ) { print STDERR join( "\t", @feat_names ) . "\n"; exit(); } } my ($chr) = $name =~ /$name_re/; $chr = sprintf( "%02i", $chr ); map { $seen{ substr( uc($_), 0, $name_len ) } = 1 } @feat_names; my $start = sprintf( "%09i", $feat->start ); my $stop = sprintf( "%09i", $feat->stop ); my $strand = ( $feat->strand =~ /-/ ) ? -1 : 1; my $header = $chr . "||" . $name . "||" . $start . "||" . $stop . "||" . $strand . "||" . uc( $feat->feature_type->name ) . "||" . $feat->feature_id; $order{$header} = 1; print LOC ">" . $header . "\n"; print LOC $feat->genomic_sequence() . "\n"; } } open( ORDER, ">", $org . ".order" ); map { print ORDER $_ . "\n" } sort keys %order; close(ORDER); } sub get_10kmers { my ( $org, $datasets ) = @_; my %files; my %order; foreach my $gs ( $s->resultset('GenomicSequence')->search( { 'dataset_id' => { 'IN' => $datasets }, 'chromosome' => { 'NOT LIKE' => '%super%' } }, { order_by => ['start'] } ) ) { my ($chr) = $gs->chromosome =~ /(\d+)/; my $file = $org . "_" . $chr . ".fasta"; my $FH; if ( !$files{$file} ) { open( $FH, ">", $file ); $files{$file} = $FH; } else { $FH = $files{$file}; } my $header = $chr . "||NONE||" . sprintf( "%09i", $gs->start() ); print $FH ">" . $header . "\n"; print $FH $gs->sequence_data() . "\n"; $order{$header} = 1; } open( ORDER, ">", $org . ".order" ); map { print ORDER $_ . "\n" } sort keys %order; close(ORDER); }
LyonsLab/coge
scripts/old/get_by_name.pl
Perl
bsd-2-clause
4,221
=head1 AmiGO::KVStore::QuickGO Wrapper for QuickGO ontology visualization. Final layer in storage/cache. =cut package AmiGO::KVStore::QuickGO; use base ("AmiGO::KVStore"); =item new # Sets the right parameters for the super class. =cut sub new { ## my $class = shift; my $self = $class->SUPER::new('qg_ont'); bless $self, $class; return $self; } 1;
geneontology/amigo
perl/lib/AmiGO/KVStore/QuickGO.pm
Perl
bsd-3-clause
373
# WARNING # Do not edit this file manually. Your changes will be overwritten with next FlowPDF update. # WARNING package FlowPDF::Component::EF::Reporting::Transformer; use base qw/FlowPDF::BaseClass2/; no warnings qw/redefine/; use FlowPDF::Types; use FlowPDF::Exception::RuntimeException; __PACKAGE__->defineClass({ pluginObject => FlowPDF::Types::Any(), transformScript => FlowPDF::Types::Scalar(), transformer => FlowPDF::Types::Reference('EC::Mapper::Transformer'), }); use strict; use warnings; use FlowPDF::Log; sub load { my ($self) = @_; my $transformScript = $self->getTransformScript(); if (!$transformScript) { logInfo("No transform script has been provided"); return $self; } my $tempTransformer = "package EC::Mapper::Transformer;\n" . q|sub transform {my ($payload) = @_; return $payload}| . "\n" . q|no warnings 'redefine';| . $transformScript . "1;\n"; eval $tempTransformer; if ($@) { FlowPDF::Exception::RuntimeException->new("Error occured during loading of transform script: $@")->throw(); } my $transformer = {}; my $blessedTransformer = bless $transformer, "EC::Mapper::Transformer"; $self->setTransformer($blessedTransformer); return $self; } sub transform { my ($self, $record) = @_; logInfo("Transformer object:", Dumper $self); my $blessedTransformer = $self->getTransformer(); return $blessedTransformer->transform($record); } 1;
electric-cloud/EC-WebLogic
src/main/resources/project/pdk/FlowPDF/Component/EF/Reporting/Transformer.pm
Perl
apache-2.0
1,512
#!/usr/bin/perl #------------------------ # Writer: Mico Cheng # Version: 2004080301 # Use for: Compare different and output to a list-file: # Host: -- #----------------------- # this month (newest/more) file list $primary_list = "./MailCheck"; # last month file list $compared_list = "./MailPass"; $output_list = "./different.list"; open (PRIMARY, "$primary_list") or die "can\'t open $primary_list:$!\n"; open (COMPARED, "$compared_list") or die "can\'t open $compared_list:$!\n"; open (OUTPUT, ">$output_list") or die "can\'t open $oes_unlist:$!\n"; while(<PRIMARY>) { chomp; $primary_count++; push(@primary_arr, $_); } while(<COMPARED>) { chomp; $compared_count++; push(@compared_arr, $_); } @primary_arr = sort(@primary_arr); @compared_arr = sort(@compared_arr); &binary_search; close PRIMARY; close COMPARED; close OUTPUT; #------------------------------------------- sub binary_search { my($i,$high,$middle,$low); $i = 0; while ($i <= $primary_count-1) { $match = 0; $high = $compared_count-1; $low = 0; until ($low > $high) { $middle = int(($low+$high)/2); if ($primary_arr[$i] eq $compared_arr[$middle]) { $match = 1; last; } elsif ($primary_arr[$i] lt $compared_arr[$middle]) { $high = $middle-1; next; } else { $low = $middle+1; next; } } if ($match == 0) { print OUTPUT "$primary_arr[$i]\n"; } $i++; } }
TonyChengTW/SMTPTools
DB/compare.pl
Perl
apache-2.0
1,653
# 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. use strict; use warnings; use Bio::EnsEMBL::Registry; ## Load the registry automatically my $reg = "Bio::EnsEMBL::Registry"; $reg->load_registry_from_url('mysql://anonymous@ensembldb.ensembl.org'); ## Get the compara member adaptor my $gene_member_adaptor = $reg->get_adaptor("Multi", "compara", "GeneMember"); ## Get the compara gene tree adaptor my $gene_tree_adaptor = $reg->get_adaptor("Multi", "compara", "GeneTree"); ## Get the compara member my $gene_member = $gene_member_adaptor->fetch_by_stable_id("ENSDARG00000003399"); ## Get the tree for this member my $tree = $gene_tree_adaptor->fetch_default_for_Member($gene_member); ## Tip: will make the traversal of the tree faster $tree->preload(); ## Will iterate over all the nodes of a tree sub count_duplications_iterative { my $root = shift; my $n_dup = 0; foreach my $node (@{$root->get_all_nodes()}) { if ((not $node->is_leaf()) and ($node->get_tagvalue('node_type') eq 'duplication')) { print "There is a duplication at the taxon '", $node->get_tagvalue('taxon_name'), "'\n"; $n_dup++; } } return $n_dup; } ## Will call recursively children() to go through all the branches sub count_duplications_recursive { my $node = shift; ## Is it a leaf or an internal node ? if ($node->is_leaf()) { return 0; } my $s = 0; if ($node->get_tagvalue('node_type') eq 'duplication') { $s++; print "There is a duplication at the taxon '", $node->get_tagvalue('taxon_name'), "'\n"; } foreach my $child_node (@{$node->children()}) { $s += count_duplications_recursive($child_node); } return $s; } print "The tree ", $tree->stable_id(), " contains ", count_duplications_recursive($tree->root), " duplication nodes.\n"; print "The tree ", $tree->stable_id(), " contains ", count_duplications_iterative($tree->root), " duplication nodes.\n";
ckongEbi/ensembl-compara
docs/workshop/API_workshop_exercises/gene_tree3.pl
Perl
apache-2.0
2,523
package AsposePdfCloud::Object::NumberStyle; require 5.6.0; use strict; use warnings; use utf8; use JSON qw(decode_json); use Data::Dumper; use Module::Runtime qw(use_module); use Log::Any qw($log); use Date::Parse; use DateTime; use base "AsposePdfCloud::Object::BaseObject"; # # # #NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. # my $swagger_types = { }; my $attribute_map = { }; # new object sub new { my ($class, %args) = @_; my $self = { }; return bless $self, $class; } # get swagger type of the attribute sub get_swagger_types { return $swagger_types; } # get attribute mappping sub get_attribute_map { return $attribute_map; } 1;
farooqsheikhpk/Aspose.Pdf-for-Cloud
SDKs/Aspose.Pdf-Cloud-SDK-for-Perl/lib/AsposePdfCloud/Object/NumberStyle.pm
Perl
mit
758
/* Part of SWI-Prolog Author: Markus Triska E-mail: triska@metalevel.at WWW: http://www.swi-prolog.org Copyright (C): 2005-2016, Markus Triska 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(simplex, [ assignment/2, constraint/3, constraint/4, constraint_add/4, gen_state/1, gen_state_clpr/1, gen_state_clpr/2, maximize/3, minimize/3, objective/2, shadow_price/3, transportation/4, variable_value/3 ]). :- if(exists_source(library(clpr))). :- use_module(library(clpr)). :- endif. :- use_module(library(assoc)). :- use_module(library(pio)). :- autoload(library(apply), [foldl/4, maplist/2, maplist/3]). :- autoload(library(lists), [flatten/2, member/2, nth0/3, reverse/2, select/3]). /** <module> Solve linear programming problems ## Introduction {#simplex-intro} A *linear programming problem* or simply *linear program* (LP) consists of: - a set of _linear_ **constraints** - a set of **variables** - a _linear_ **objective function**. The goal is to assign values to the variables so as to _maximize_ (or minimize) the value of the objective function while satisfying all constraints. Many optimization problems can be modeled in this way. As one basic example, consider a knapsack with fixed capacity C, and a number of items with sizes `s(i)` and values `v(i)`. The goal is to put as many items as possible in the knapsack (not exceeding its capacity) while maximizing the sum of their values. As another example, suppose you are given a set of _coins_ with certain values, and you are to find the minimum number of coins such that their values sum up to a fixed amount. Instances of these problems are solved below. All numeric quantities are converted to rationals via `rationalize/1`, and rational arithmetic is used throughout solving linear programs. In the current implementation, all variables are implicitly constrained to be _non-negative_. This may change in future versions, and non-negativity constraints should therefore be stated explicitly. ## Example 1 {#simplex-ex-1} This is the "radiation therapy" example, taken from _Introduction to Operations Research_ by Hillier and Lieberman. [**Prolog DCG notation**](https://www.metalevel.at/prolog/dcg) is used to _implicitly_ thread the state through posting the constraints: == :- use_module(library(simplex)). radiation(S) :- gen_state(S0), post_constraints(S0, S1), minimize([0.4*x1, 0.5*x2], S1, S). post_constraints --> constraint([0.3*x1, 0.1*x2] =< 2.7), constraint([0.5*x1, 0.5*x2] = 6), constraint([0.6*x1, 0.4*x2] >= 6), constraint([x1] >= 0), constraint([x2] >= 0). == An example query: == ?- radiation(S), variable_value(S, x1, Val1), variable_value(S, x2, Val2). Val1 = 15 rdiv 2, Val2 = 9 rdiv 2. == ## Example 2 {#simplex-ex-2} Here is an instance of the knapsack problem described above, where `C = 8`, and we have two types of items: One item with value 7 and size 6, and 2 items each having size 4 and value 4. We introduce two variables, `x(1)` and `x(2)` that denote how many items to take of each type. == :- use_module(library(simplex)). knapsack(S) :- knapsack_constraints(S0), maximize([7*x(1), 4*x(2)], S0, S). knapsack_constraints(S) :- gen_state(S0), constraint([6*x(1), 4*x(2)] =< 8, S0, S1), constraint([x(1)] =< 1, S1, S2), constraint([x(2)] =< 2, S2, S). == An example query yields: == ?- knapsack(S), variable_value(S, x(1), X1), variable_value(S, x(2), X2). X1 = 1 X2 = 1 rdiv 2. == That is, we are to take the one item of the first type, and half of one of the items of the other type to maximize the total value of items in the knapsack. If items can not be split, integrality constraints have to be imposed: == knapsack_integral(S) :- knapsack_constraints(S0), constraint(integral(x(1)), S0, S1), constraint(integral(x(2)), S1, S2), maximize([7*x(1), 4*x(2)], S2, S). == Now the result is different: == ?- knapsack_integral(S), variable_value(S, x(1), X1), variable_value(S, x(2), X2). X1 = 0 X2 = 2 == That is, we are to take only the _two_ items of the second type. Notice in particular that always choosing the remaining item with best performance (ratio of value to size) that still fits in the knapsack does not necessarily yield an optimal solution in the presence of integrality constraints. ## Example 3 {#simplex-ex-3} We are given: - 3 coins each worth 1 unit - 20 coins each worth 5 units and - 10 coins each worth 20 units. The task is to find a _minimal_ number of these coins that amount to 111 units in total. We introduce variables `c(1)`, `c(5)` and `c(20)` denoting how many coins to take of the respective type: == :- use_module(library(simplex)). coins(S) :- gen_state(S0), coins(S0, S). coins --> constraint([c(1), 5*c(5), 20*c(20)] = 111), constraint([c(1)] =< 3), constraint([c(5)] =< 20), constraint([c(20)] =< 10), constraint([c(1)] >= 0), constraint([c(5)] >= 0), constraint([c(20)] >= 0), constraint(integral(c(1))), constraint(integral(c(5))), constraint(integral(c(20))), minimize([c(1), c(5), c(20)]). == An example query: == ?- coins(S), variable_value(S, c(1), C1), variable_value(S, c(5), C5), variable_value(S, c(20), C20). C1 = 1, C5 = 2, C20 = 5. == @author [Markus Triska](https://www.metalevel.at) */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CLP(R) bindings the (unsolved) state is stored as a structure of the form clpr_state(Options, Cs, Is) Options: list of Option=Value pairs, currently only eps=Eps Cs: list of constraints, i.e., structures of the form c(Name, Left, Op, Right) anonymous constraints have Name == 0 Is: list of integral variables - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ gen_state_clpr(State) :- gen_state_clpr([], State). gen_state_clpr(Options, State) :- ( memberchk(eps=_, Options) -> Options1 = Options ; Options1 = [eps=1.0e-6|Options] ), State = clpr_state(Options1, [], []). clpr_state_options(clpr_state(Os, _, _), Os). clpr_state_constraints(clpr_state(_, Cs, _), Cs). clpr_state_integrals(clpr_state(_, _, Is), Is). clpr_state_add_integral(I, clpr_state(Os, Cs, Is), clpr_state(Os, Cs, [I|Is])). clpr_state_add_constraint(C, clpr_state(Os, Cs, Is), clpr_state(Os, [C|Cs], Is)). clpr_state_set_constraints(Cs, clpr_state(Os,_,Is), clpr_state(Os, Cs, Is)). clpr_constraint(Name, Constraint, S0, S) :- ( Constraint = integral(Var) -> clpr_state_add_integral(Var, S0, S) ; Constraint =.. [Op,Left,Right], coeff_one(Left, Left1), clpr_state_add_constraint(c(Name, Left1, Op, Right), S0, S) ). clpr_constraint(Constraint, S0, S) :- clpr_constraint(0, Constraint, S0, S). clpr_shadow_price(clpr_solved(_,_,Duals,_), Name, Value) :- memberchk(Name-Value0, Duals), Value is Value0. %( var(Value0) -> % Value = 0 %; % Value is Value0 %). clpr_make_variables(Cs, Aliases) :- clpr_constraints_variables(Cs, Variables0, []), sort(Variables0, Variables1), pairs_keys(Aliases, Variables1). clpr_constraints_variables([]) --> []. clpr_constraints_variables([c(_, Left, _, _)|Cs]) --> variables(Left), clpr_constraints_variables(Cs). clpr_set_up(Aliases, c(_Name, Left, Op, Right)) :- clpr_translate_linsum(Left, Aliases, LinSum), CLPRConstraint =.. [Op, LinSum, Right], clpr:{ CLPRConstraint }. clpr_set_up_noneg(Aliases, Var) :- memberchk(Var-CLPVar, Aliases), { CLPVar >= 0 }. clpr_translate_linsum([], _, 0). clpr_translate_linsum([Coeff*Var|Ls], Aliases, LinSum) :- memberchk(Var-CLPVar, Aliases), LinSum = Coeff*CLPVar + LinRest, clpr_translate_linsum(Ls, Aliases, LinRest). clpr_dual(Objective0, S0, DualValues) :- clpr_state_constraints(S0, Cs0), clpr_constraints_variables(Cs0, Variables0, []), sort(Variables0, Variables1), maplist(clpr_standard_form, Cs0, Cs1), clpr_include_all_vars(Cs1, Variables1, Cs2), clpr_merge_into(Variables1, Objective0, Objective, []), clpr_unique_names(Cs2, 0, Names), maplist(clpr_constraint_coefficient, Cs2, Coefficients), lists_transpose(Coefficients, TCs), maplist(clpr_dual_constraints(Names), TCs, Objective, DualConstraints), phrase(clpr_nonneg_constraints(Cs2, Names), DualNonNeg), append(DualConstraints, DualNonNeg, DualConstraints1), maplist(clpr_dual_objective, Cs2, Names, DualObjective), clpr_make_variables(DualConstraints1, Aliases), maplist(clpr_set_up(Aliases), DualConstraints1), clpr_translate_linsum(DualObjective, Aliases, LinExpr), minimize(LinExpr), Aliases = DualValues. clpr_dual_objective(c(_, _, _, Right), Name, Right*Name). clpr_nonneg_constraints([], _) --> []. clpr_nonneg_constraints([C|Cs], [Name|Names]) --> { C = c(_, _, Op, _) }, ( { Op == (=<) } -> [c(0, [1*Name], (>=), 0)] ; [] ), clpr_nonneg_constraints(Cs, Names). clpr_dual_constraints(Names, Coeffs, O*_, Constraint) :- maplist(clpr_dual_linsum, Coeffs, Names, Linsum), Constraint = c(0, Linsum, (>=), O). clpr_dual_linsum(Coeff, Name, Coeff*Name). clpr_constraint_coefficient(c(_, Left, _, _), Coeff) :- maplist(all_coeffs, Left, Coeff). all_coeffs(Coeff*_, Coeff). clpr_unique_names([], _, []). clpr_unique_names([C0|Cs0], Num, [N|Ns]) :- C0 = c(Name, _, _, _), ( Name == 0 -> N = Num, Num1 is Num + 1 ; N = Name, Num1 = Num ), clpr_unique_names(Cs0, Num1, Ns). clpr_include_all_vars([], _, []). clpr_include_all_vars([C0|Cs0], Variables, [C|Cs]) :- C0 = c(Name, Left0, Op, Right), clpr_merge_into(Variables, Left0, Left, []), C = c(Name, Left, Op, Right), clpr_include_all_vars(Cs0, Variables, Cs). clpr_merge_into([], _, Ls, Ls). clpr_merge_into([V|Vs], Left, Ls0, Ls) :- ( member(Coeff*V, Left) -> Ls0 = [Coeff*V|Rest] ; Ls0 = [0*V|Rest] ), clpr_merge_into(Vs, Left, Rest, Ls). clpr_maximize(Expr0, S0, S) :- coeff_one(Expr0, Expr), clpr_state_constraints(S0, Cs), clpr_make_variables(Cs, Aliases), maplist(clpr_set_up(Aliases), Cs), clpr_constraints_variables(Cs, Variables0, []), sort(Variables0, Variables1), maplist(clpr_set_up_noneg(Aliases), Variables1), clpr_translate_linsum(Expr, Aliases, LinExpr), clpr_state_integrals(S0, Is), ( Is == [] -> maximize(LinExpr), Sup is LinExpr, clpr_dual(Expr, S0, DualValues), S = clpr_solved(Sup, Aliases, DualValues, S0) ; clpr_state_options(S0, Options), memberchk(eps=Eps, Options), maplist(clpr_fetch_var(Aliases), Is, Vars), bb_inf(Vars, -LinExpr, Sup, Vertex, Eps), pairs_keys_values(Values, Is, Vertex), % what about the dual in MIPs? Sup1 is -Sup, S = clpr_solved(Sup1, Values, [], S0) ). clpr_minimize(Expr0, S0, S) :- coeff_one(Expr0, Expr1), maplist(linsum_negate, Expr1, Expr2), clpr_maximize(Expr2, S0, S1), S1 = clpr_solved(Sup, Values, Duals, S0), Inf is -Sup, S = clpr_solved(Inf, Values, Duals, S0). clpr_fetch_var(Aliases, Var, X) :- memberchk(Var-X, Aliases). clpr_variable_value(clpr_solved(_, Aliases, _, _), Variable, Value) :- memberchk(Variable-Value0, Aliases), Value is Value0. %( var(Value0) -> % Value = 0 %; % Value is Value0 %). clpr_objective(clpr_solved(Obj, _, _, _), Obj). clpr_standard_form(c(Name, Left, Op, Right), S) :- clpr_standard_form_(Op, Name, Left, Right, S). clpr_standard_form_((=), Name, Left, Right, c(Name, Left, (=), Right)). clpr_standard_form_((>=), Name, Left, Right, c(Name, Left1, (=<), Right1)) :- Right1 is -Right, maplist(linsum_negate, Left, Left1). clpr_standard_form_((=<), Name, Left, Right, c(Name, Left, (=<), Right)). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - General Simplex Algorithm Structures used: tableau(Objective, Variables, Indicators, Constraints) *) objective function, represented as row *) list of variables corresponding to columns *) indicators denoting which variables are still active *) constraints as rows row(Var, Left, Right) *) the basic variable corresponding to this row *) coefficients of the left-hand side of the constraint *) right-hand side of the constraint - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ find_row(Variable, [Row|Rows], R) :- Row = row(V, _, _), ( V == Variable -> R = Row ; find_row(Variable, Rows, R) ). %% variable_value(+State, +Variable, -Value) % % Value is unified with the value obtained for Variable. State must % correspond to a solved instance. variable_value(State, Variable, Value) :- functor(State, F, _), ( F == solved -> solved_tableau(State, Tableau), tableau_rows(Tableau, Rows), ( find_row(Variable, Rows, Row) -> Row = row(_, _, Value) ; Value = 0 ) ; F == clpr_solved -> clpr_variable_value(State, Variable, Value) ). var_zero(State, _Coeff*Var) :- variable_value(State, Var, 0). list_first(Ls, F, Index) :- once(nth0(Index, Ls, F)). %% shadow_price(+State, +Name, -Value) % % Unifies Value with the shadow price corresponding to the linear % constraint whose name is Name. State must correspond to a solved % instance. shadow_price(State, Name, Value) :- functor(State, F, _), ( F == solved -> solved_tableau(State, Tableau), tableau_objective(Tableau, row(_,Left,_)), tableau_variables(Tableau, Variables), solved_names(State, Names), memberchk(user(Name)-Var, Names), list_first(Variables, Var, Nth0), nth0(Nth0, Left, Value) ; F == clpr_solved -> clpr_shadow_price(State, Name, Value) ). %% objective(+State, -Objective) % % Unifies Objective with the result of the objective function at the % obtained extremum. State must correspond to a solved instance. objective(State, Obj) :- functor(State, F, _), ( F == solved -> solved_tableau(State, Tableau), tableau_objective(Tableau, Objective), Objective = row(_, _, Obj) ; clpr_objective(State, Obj) ). % interface functions that access tableau components tableau_objective(tableau(Obj, _, _, _), Obj). tableau_rows(tableau(_, _, _, Rows), Rows). tableau_indicators(tableau(_, _, Inds, _), Inds). tableau_variables(tableau(_, Vars, _, _), Vars). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - interface functions that access and modify state components state is a structure of the form state(Num, Names, Cs, Is) Num: used to obtain new unique names for slack variables in a side-effect free way (increased by one and threaded through) Names: list of Name-Var, correspondence between constraint-names and names of slack/artificial variables to obtain shadow prices later Cs: list of constraints Is: list of integer variables constraints are initially represented as c(Name, Left, Op, Right), and after normalizing as c(Var, Left, Right). Name of unnamed constraints is 0. The distinction is important for merging constraints (mainly in branch and bound) with existing ones. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ constraint_name(c(Name, _, _, _), Name). constraint_op(c(_, _, Op, _), Op). constraint_left(c(_, Left, _, _), Left). constraint_right(c(_, _, _, Right), Right). %% gen_state(-State) % % Generates an initial state corresponding to an empty linear program. gen_state(state(0,[],[],[])). state_add_constraint(C, S0, S) :- ( constraint_name(C, 0), constraint_left(C, [_Coeff*_Var]) -> state_merge_constraint(C, S0, S) ; state_add_constraint_(C, S0, S) ). state_add_constraint_(C, state(VID,Ns,Cs,Is), state(VID,Ns,[C|Cs],Is)). state_merge_constraint(C, S0, S) :- constraint_left(C, [Coeff0*Var0]), constraint_right(C, Right0), constraint_op(C, Op), ( Coeff0 =:= 0 -> ( Op == (=) -> Right0 =:= 0, S0 = S ; Op == (=<) -> S0 = S ; Op == (>=) -> Right0 =:= 0, S0 = S ) ; Coeff0 < 0 -> state_add_constraint_(C, S0, S) ; Right is Right0 rdiv Coeff0, state_constraints(S0, Cs), ( select(c(0, [1*Var0], Op, CRight), Cs, RestCs) -> ( Op == (=) -> CRight =:= Right, S0 = S ; Op == (=<) -> NewRight is min(Right, CRight), NewCs = [c(0, [1*Var0], Op, NewRight)|RestCs], state_set_constraints(NewCs, S0, S) ; Op == (>=) -> NewRight is max(Right, CRight), NewCs = [c(0, [1*Var0], Op, NewRight)|RestCs], state_set_constraints(NewCs, S0, S) ) ; state_add_constraint_(c(0, [1*Var0], Op, Right), S0, S) ) ). state_add_name(Name, Var), [state(VID,[Name-Var|Ns],Cs,Is)] --> [state(VID,Ns,Cs,Is)]. state_add_integral(Var, state(VID,Ns,Cs,Is), state(VID,Ns,Cs,[Var|Is])). state_constraints(state(_, _, Cs, _), Cs). state_names(state(_,Names,_,_), Names). state_integrals(state(_,_,_,Is), Is). state_set_constraints(Cs, state(VID,Ns,_,Is), state(VID,Ns,Cs,Is)). state_set_integrals(Is, state(VID,Ns,Cs,_), state(VID,Ns,Cs,Is)). state_next_var(VarID0), [state(VarID1,Names,Cs,Is)] --> [state(VarID0,Names,Cs,Is)], { VarID1 is VarID0 + 1 }. solved_tableau(solved(Tableau, _, _), Tableau). solved_names(solved(_, Names,_), Names). solved_integrals(solved(_,_,Is), Is). % User-named constraints are wrapped with user/1 to also allow "0" in % constraint names. %% constraint(+Constraint, +S0, -S) % % Adds a linear or integrality constraint to the linear program % corresponding to state S0. A linear constraint is of the form =|Left % Op C|=, where `Left` is a list of `Coefficient*Variable` terms % (variables in the context of linear programs can be atoms or % compound terms) and `C` is a non-negative numeric constant. The list % represents the sum of its elements. `Op` can be `=`, `=<` or `>=`. % The coefficient `1` can be omitted. An integrality constraint is of % the form integral(Variable) and constrains Variable to an integral % value. constraint(C, S0, S) :- functor(S0, F, _), ( F == state -> ( C = integral(Var) -> state_add_integral(Var, S0, S) ; constraint_(0, C, S0, S) ) ; F == clpr_state -> clpr_constraint(C, S0, S) ). %% constraint(+Name, +Constraint, +S0, -S) % % Like constraint/3, and attaches the name Name (an atom or compound % term) to the new constraint. constraint(Name, C, S0, S) :- constraint_(user(Name), C, S0, S). constraint_(Name, C, S0, S) :- functor(S0, F, _), ( F == state -> ( C = integral(Var) -> state_add_integral(Var, S0, S) ; C =.. [Op, Left0, Right0], coeff_one(Left0, Left), Right0 >= 0, Right is rationalize(Right0), state_add_constraint(c(Name, Left, Op, Right), S0, S) ) ; F == clpr_state -> clpr_constraint(Name, C, S0, S) ). %% constraint_add(+Name, +Left, +S0, -S) % % Left is a list of `Coefficient*Variable` terms. The terms are added % to the left-hand side of the constraint named Name. S is unified % with the resulting state. constraint_add(Name, A, S0, S) :- functor(S0, F, _), ( F == state -> state_constraints(S0, Cs), add_left(Cs, user(Name), A, Cs1), state_set_constraints(Cs1, S0, S) ; F == clpr_state -> clpr_state_constraints(S0, Cs), add_left(Cs, Name, A, Cs1), clpr_state_set_constraints(Cs1, S0, S) ). add_left([c(Name,Left0,Op,Right)|Cs], V, A, [c(Name,Left,Op,Right)|Rest]) :- ( Name == V -> append(A, Left0, Left), Rest = Cs ; Left0 = Left, add_left(Cs, V, A, Rest) ). branching_variable(State, Variable) :- solved_integrals(State, Integrals), member(Variable, Integrals), variable_value(State, Variable, Value), \+ integer(Value). worth_investigating(ZStar0, _, _) :- var(ZStar0). worth_investigating(ZStar0, AllInt, Z) :- nonvar(ZStar0), ( AllInt =:= 1 -> Z1 is floor(Z) ; Z1 = Z ), Z1 > ZStar0. branch_and_bound(Objective, Solved, AllInt, ZStar0, ZStar, S0, S, Found) :- objective(Solved, Z), ( worth_investigating(ZStar0, AllInt, Z) -> ( branching_variable(Solved, BrVar) -> variable_value(Solved, BrVar, Value), Value1 is floor(Value), Value2 is Value1 + 1, constraint([BrVar] =< Value1, S0, SubProb1), ( maximize_(Objective, SubProb1, SubSolved1) -> Sub1Feasible = 1, objective(SubSolved1, Obj1) ; Sub1Feasible = 0 ), constraint([BrVar] >= Value2, S0, SubProb2), ( maximize_(Objective, SubProb2, SubSolved2) -> Sub2Feasible = 1, objective(SubSolved2, Obj2) ; Sub2Feasible = 0 ), ( Sub1Feasible =:= 1, Sub2Feasible =:= 1 -> ( Obj1 >= Obj2 -> First = SubProb1, Second = SubProb2, FirstSolved = SubSolved1, SecondSolved = SubSolved2 ; First = SubProb2, Second = SubProb1, FirstSolved = SubSolved2, SecondSolved = SubSolved1 ), branch_and_bound(Objective, FirstSolved, AllInt, ZStar0, ZStar1, First, Solved1, Found1), branch_and_bound(Objective, SecondSolved, AllInt, ZStar1, ZStar2, Second, Solved2, Found2) ; Sub1Feasible =:= 1 -> branch_and_bound(Objective, SubSolved1, AllInt, ZStar0, ZStar1, SubProb1, Solved1, Found1), Found2 = 0 ; Sub2Feasible =:= 1 -> Found1 = 0, branch_and_bound(Objective, SubSolved2, AllInt, ZStar0, ZStar2, SubProb2, Solved2, Found2) ; Found1 = 0, Found2 = 0 ), ( Found1 =:= 1, Found2 =:= 1 -> S = Solved2, ZStar = ZStar2 ; Found1 =:= 1 -> S = Solved1, ZStar = ZStar1 ; Found2 =:= 1 -> S = Solved2, ZStar = ZStar2 ; S = S0, ZStar = ZStar0 ), Found is max(Found1, Found2) ; S = Solved, ZStar = Z, Found = 1 ) ; ZStar = ZStar0, S = S0, Found = 0 ). %% maximize(+Objective, +S0, -S) % % Maximizes the objective function, stated as a list of % `Coefficient*Variable` terms that represents the sum of its % elements, with respect to the linear program corresponding to state % S0. \arg{S} is unified with an internal representation of the solved % instance. maximize(Z0, S0, S) :- coeff_one(Z0, Z1), functor(S0, F, _), ( F == state -> maximize_mip(Z1, S0, S) ; F == clpr_state -> clpr_maximize(Z1, S0, S) ). maximize_mip(Z, S0, S) :- maximize_(Z, S0, Solved), state_integrals(S0, Is), ( Is == [] -> S = Solved ; % arrange it so that branch and bound branches on variables % in the same order the integrality constraints were stated in reverse(Is, Is1), state_set_integrals(Is1, S0, S1), ( all_integers(Z, Is1) -> AllInt = 1 ; AllInt = 0 ), branch_and_bound(Z, Solved, AllInt, _, _, S1, S, 1) ). all_integers([], _). all_integers([Coeff*V|Rest], Is) :- integer(Coeff), memberchk(V, Is), all_integers(Rest, Is). %% minimize(+Objective, +S0, -S) % % Analogous to maximize/3. minimize(Z0, S0, S) :- coeff_one(Z0, Z1), functor(S0, F, _), ( F == state -> maplist(linsum_negate, Z1, Z2), maximize_mip(Z2, S0, S1), solved_tableau(S1, tableau(Obj, Vars, Inds, Rows)), solved_names(S1, Names), Obj = row(z, Left0, Right0), all_times(Left0, -1, Left), Right is -Right0, Obj1 = row(z, Left, Right), state_integrals(S0, Is), S = solved(tableau(Obj1, Vars, Inds, Rows), Names, Is) ; F == clpr_state -> clpr_minimize(Z1, S0, S) ). op_pendant(>=, =<). op_pendant(=<, >=). constraints_collapse([]) --> []. constraints_collapse([C|Cs]) --> { C = c(Name, Left, Op, Right) }, ( { Name == 0, Left = [1*Var], op_pendant(Op, P) } -> { Pendant = c(0, [1*Var], P, Right) }, ( { select(Pendant, Cs, Rest) } -> [c(0, Left, (=), Right)], { CsLeft = Rest } ; [C], { CsLeft = Cs } ) ; [C], { CsLeft = Cs } ), constraints_collapse(CsLeft). % solve a (relaxed) LP in standard form maximize_(Z, S0, S) :- state_constraints(S0, Cs0), phrase(constraints_collapse(Cs0), Cs1), phrase(constraints_normalize(Cs1, Cs, As0), [S0], [S1]), flatten(As0, As1), ( As1 == [] -> make_tableau(Z, Cs, Tableau0), simplex(Tableau0, Tableau), state_names(S1, Names), state_integrals(S1, Is), S = solved(Tableau, Names, Is) ; state_names(S1, Names), state_integrals(S1, Is), two_phase_simplex(Z, Cs, As1, Names, Is, S) ). make_tableau(Z, Cs, Tableau) :- ZC = c(_, Z, _), phrase(constraints_variables([ZC|Cs]), Variables0), sort(Variables0, Variables), constraints_rows(Cs, Variables, Rows), linsum_row(Variables, Z, Objective1), all_times(Objective1, -1, Obj), length(Variables, LVs), length(Ones, LVs), all_one(Ones), Tableau = tableau(row(z, Obj, 0), Variables, Ones, Rows). all_one(Ones) :- maplist(=(1), Ones). proper_form(Variables, Rows, _Coeff*A, Obj0, Obj) :- ( find_row(A, Rows, PivotRow) -> list_first(Variables, A, Col), row_eliminate(Obj0, PivotRow, Col, Obj) ; Obj = Obj0 ). two_phase_simplex(Z, Cs, As, Names, Is, S) :- % phase 1: minimize sum of articifial variables make_tableau(As, Cs, Tableau0), Tableau0 = tableau(Obj0, Variables, Inds, Rows), foldl(proper_form(Variables, Rows), As, Obj0, Obj), simplex(tableau(Obj, Variables, Inds, Rows), Tableau1), maplist(var_zero(solved(Tableau1, _, _)), As), % phase 2: remove artificial variables and solve actual LP. tableau_rows(Tableau1, Rows2), eliminate_artificial(As, As, Variables, Rows2, Rows3), list_nths(As, Variables, Nths0), nths_to_zero(Nths0, Inds, Inds1), linsum_row(Variables, Z, Objective), all_times(Objective, -1, Objective1), foldl(proper_form(Variables, Rows3), Z, row(z, Objective1, 0), ObjRow), simplex(tableau(ObjRow, Variables, Inds1, Rows3), Tableau), S = solved(Tableau, Names, Is). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - If artificial variables are still in the basis, replace them with non-artificial variables if possible. If that is not possible, the constraint is ignored because it is redundant. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ eliminate_artificial([], _, _, Rows, Rows). eliminate_artificial([_Coeff*A|Rest], As, Variables, Rows0, Rows) :- ( select(row(A, Left, 0), Rows0, Others) -> ( nth0(Col, Left, Coeff), Coeff =\= 0, nth0(Col, Variables, Var), \+ memberchk(_*Var, As) -> row_divide(row(A, Left, 0), Coeff, Row), gauss_elimination(Rows0, Row, Col, Rows1), swap_basic(Rows1, A, Var, Rows2) ; Rows2 = Others ) ; Rows2 = Rows0 ), eliminate_artificial(Rest, As, Variables, Rows2, Rows). nths_to_zero([], Inds, Inds). nths_to_zero([Nth|Nths], Inds0, Inds) :- nth_to_zero(Inds0, 0, Nth, Inds1), nths_to_zero(Nths, Inds1, Inds). nth_to_zero([], _, _, []). nth_to_zero([I|Is], Curr, Nth, [Z|Zs]) :- ( Curr =:= Nth -> [Z|Zs] = [0|Is] ; Z = I, Next is Curr + 1, nth_to_zero(Is, Next, Nth, Zs) ). list_nths([], _, []). list_nths([_Coeff*A|As], Variables, [Nth|Nths]) :- list_first(Variables, A, Nth), list_nths(As, Variables, Nths). linsum_negate(Coeff0*Var, Coeff*Var) :- Coeff is -Coeff0. linsum_row([], _, []). linsum_row([V|Vs], Ls, [C|Cs]) :- ( member(Coeff*V, Ls) -> C is rationalize(Coeff) ; C = 0 ), linsum_row(Vs, Ls, Cs). constraints_rows([], _, []). constraints_rows([C|Cs], Vars, [R|Rs]) :- C = c(Var, Left0, Right), linsum_row(Vars, Left0, Left), R = row(Var, Left, Right), constraints_rows(Cs, Vars, Rs). constraints_normalize([], [], []) --> []. constraints_normalize([C0|Cs0], [C|Cs], [A|As]) --> { constraint_op(C0, Op), constraint_left(C0, Left), constraint_right(C0, Right), constraint_name(C0, Name), Con =.. [Op, Left, Right] }, constraint_normalize(Con, Name, C, A), constraints_normalize(Cs0, Cs, As). constraint_normalize(As0 =< B0, Name, c(Slack, [1*Slack|As0], B0), []) --> state_next_var(Slack), state_add_name(Name, Slack). constraint_normalize(As0 = B0, Name, c(AID, [1*AID|As0], B0), [-1*AID]) --> state_next_var(AID), state_add_name(Name, AID). constraint_normalize(As0 >= B0, Name, c(AID, [-1*Slack,1*AID|As0], B0), [-1*AID]) --> state_next_var(Slack), state_next_var(AID), state_add_name(Name, AID). coeff_one([], []). coeff_one([L|Ls], [Coeff*Var|Rest]) :- ( L = A*B -> Coeff = A, Var = B ; Coeff = 1, Var = L ), coeff_one(Ls, Rest). tableau_optimal(Tableau) :- tableau_objective(Tableau, Objective), tableau_indicators(Tableau, Indicators), Objective = row(_, Left, _), all_nonnegative(Left, Indicators). all_nonnegative([], []). all_nonnegative([Coeff|As], [I|Is]) :- ( I =:= 0 -> true ; Coeff >= 0 ), all_nonnegative(As, Is). pivot_column(Tableau, PCol) :- tableau_objective(Tableau, row(_, Left, _)), tableau_indicators(Tableau, Indicators), first_negative(Left, Indicators, 0, Index0, Val, RestL, RestI), Index1 is Index0 + 1, pivot_column(RestL, RestI, Val, Index1, Index0, PCol). first_negative([L|Ls], [I|Is], Index0, N, Val, RestL, RestI) :- Index1 is Index0 + 1, ( I =:= 0 -> first_negative(Ls, Is, Index1, N, Val, RestL, RestI) ; ( L < 0 -> N = Index0, Val = L, RestL = Ls, RestI = Is ; first_negative(Ls, Is, Index1, N, Val, RestL, RestI) ) ). pivot_column([], _, _, _, N, N). pivot_column([L|Ls], [I|Is], Coeff0, Index0, N0, N) :- ( I =:= 0 -> Coeff1 = Coeff0, N1 = N0 ; ( L < Coeff0 -> Coeff1 = L, N1 = Index0 ; Coeff1 = Coeff0, N1 = N0 ) ), Index1 is Index0 + 1, pivot_column(Ls, Is, Coeff1, Index1, N1, N). pivot_row(Tableau, PCol, PRow) :- tableau_rows(Tableau, Rows), pivot_row(Rows, PCol, false, _, 0, 0, PRow). pivot_row([], _, Bounded, _, _, Row, Row) :- Bounded. pivot_row([Row|Rows], PCol, Bounded0, Min0, Index0, PRow0, PRow) :- Row = row(_Var, Left, B), nth0(PCol, Left, Ae), ( Ae > 0 -> Bounded1 = true, Bound is B rdiv Ae, ( Bounded0 -> ( Bound < Min0 -> Min1 = Bound, PRow1 = Index0 ; Min1 = Min0, PRow1 = PRow0 ) ; Min1 = Bound, PRow1 = Index0 ) ; Bounded1 = Bounded0, Min1 = Min0, PRow1 = PRow0 ), Index1 is Index0 + 1, pivot_row(Rows, PCol, Bounded1, Min1, Index1, PRow1, PRow). row_divide(row(Var, Left0, Right0), Div, row(Var, Left, Right)) :- all_divide(Left0, Div, Left), Right is Right0 rdiv Div. all_divide([], _, []). all_divide([R|Rs], Div, [DR|DRs]) :- DR is R rdiv Div, all_divide(Rs, Div, DRs). gauss_elimination([], _, _, []). gauss_elimination([Row0|Rows0], PivotRow, Col, [Row|Rows]) :- PivotRow = row(PVar, _, _), Row0 = row(Var, _, _), ( PVar == Var -> Row = PivotRow ; row_eliminate(Row0, PivotRow, Col, Row) ), gauss_elimination(Rows0, PivotRow, Col, Rows). row_eliminate(row(Var, Ls0, R0), row(_, PLs, PR), Col, row(Var, Ls, R)) :- nth0(Col, Ls0, Coeff), ( Coeff =:= 0 -> Ls = Ls0, R = R0 ; MCoeff is -Coeff, all_times_plus([PR|PLs], MCoeff, [R0|Ls0], [R|Ls]) ). all_times_plus([], _, _, []). all_times_plus([A|As], T, [B|Bs], [AT|ATs]) :- AT is A * T + B, all_times_plus(As, T, Bs, ATs). all_times([], _, []). all_times([A|As], T, [AT|ATs]) :- AT is A * T, all_times(As, T, ATs). simplex(Tableau0, Tableau) :- ( tableau_optimal(Tableau0) -> Tableau0 = Tableau ; pivot_column(Tableau0, PCol), pivot_row(Tableau0, PCol, PRow), Tableau0 = tableau(Obj0,Variables,Inds,Matrix0), nth0(PRow, Matrix0, Row0), Row0 = row(Leaving, Left0, _Right0), nth0(PCol, Left0, PivotElement), row_divide(Row0, PivotElement, Row1), gauss_elimination([Obj0|Matrix0], Row1, PCol, [Obj|Matrix1]), nth0(PCol, Variables, Entering), swap_basic(Matrix1, Leaving, Entering, Matrix), simplex(tableau(Obj,Variables,Inds,Matrix), Tableau) ). swap_basic([Row0|Rows0], Old, New, Matrix) :- Row0 = row(Var, Left, Right), ( Var == Old -> Matrix = [row(New, Left, Right)|Rows0] ; Matrix = [Row0|Rest], swap_basic(Rows0, Old, New, Rest) ). constraints_variables([]) --> []. constraints_variables([c(_,Left,_)|Cs]) --> variables(Left), constraints_variables(Cs). variables([]) --> []. variables([_Coeff*Var|Rest]) --> [Var], variables(Rest). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - A dual algorithm ("algorithm alpha-beta" in Papadimitriou and Steiglitz) is used for transportation and assignment problems. The arising max-flow problem is solved with Edmonds-Karp, itself a dual algorithm. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - An attributed variable is introduced for each node. Attributes: node: Original name of the node. edges: arc_to(To,F,Capacity) (F has an attribute "flow") or arc_from(From,F,Capacity) parent: used in breadth-first search - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ arcs([], Assoc, Assoc). arcs([arc(From0,To0,C)|As], Assoc0, Assoc) :- ( get_assoc(From0, Assoc0, From) -> Assoc1 = Assoc0 ; put_assoc(From0, Assoc0, From, Assoc1), put_attr(From, node, From0) ), ( get_attr(From, edges, Es) -> true ; Es = [] ), put_attr(F, flow, 0), put_attr(From, edges, [arc_to(To,F,C)|Es]), ( get_assoc(To0, Assoc1, To) -> Assoc2 = Assoc1 ; put_assoc(To0, Assoc1, To, Assoc2), put_attr(To, node, To0) ), ( get_attr(To, edges, Es1) -> true ; Es1 = [] ), put_attr(To, edges, [arc_from(From,F,C)|Es1]), arcs(As, Assoc2, Assoc). edmonds_karp(Arcs0, Arcs) :- empty_assoc(E), arcs(Arcs0, E, Assoc), get_assoc(s, Assoc, S), get_assoc(t, Assoc, T), maximum_flow(S, T), % fetch attvars before deleting visited edges term_attvars(S, AttVars), phrase(flow_to_arcs(S), Ls), arcs_assoc(Ls, Arcs), maplist(del_attrs, AttVars). flow_to_arcs(V) --> ( { get_attr(V, edges, Es) } -> { del_attr(V, edges), get_attr(V, node, Name) }, flow_to_arcs_(Es, Name) ; [] ). flow_to_arcs_([], _) --> []. flow_to_arcs_([E|Es], Name) --> edge_to_arc(E, Name), flow_to_arcs_(Es, Name). edge_to_arc(arc_from(_,_,_), _) --> []. edge_to_arc(arc_to(To,F,C), Name) --> { get_attr(To, node, NTo), get_attr(F, flow, Flow) }, [arc(Name,NTo,Flow,C)], flow_to_arcs(To). arcs_assoc(Arcs, Hash) :- empty_assoc(E), arcs_assoc(Arcs, E, Hash). arcs_assoc([], Hs, Hs). arcs_assoc([arc(From,To,F,C)|Rest], Hs0, Hs) :- ( get_assoc(From, Hs0, As) -> Hs1 = Hs0 ; put_assoc(From, Hs0, [], Hs1), empty_assoc(As) ), put_assoc(To, As, arc(From,To,F,C), As1), put_assoc(From, Hs1, As1, Hs2), arcs_assoc(Rest, Hs2, Hs). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Strategy: Breadth-first search until we find a free right vertex in the value graph, then find an augmenting path in reverse. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ maximum_flow(S, T) :- ( augmenting_path([[S]], Levels, T) -> phrase(augmenting_path(S, T), Path), Path = [augment(_,First,_)|Rest], path_minimum(Rest, First, Min), % format("augmenting path: ~w\n", [Min]), maplist(augment(Min), Path), maplist(maplist(clear_parent), Levels), maximum_flow(S, T) ; true ). clear_parent(V) :- del_attr(V, parent). augmenting_path(Levels0, Levels, T) :- Levels0 = [Vs|_], Levels1 = [Tos|Levels0], phrase(reachables(Vs), Tos), Tos = [_|_], ( member(To, Tos), To == T -> Levels = Levels1 ; augmenting_path(Levels1, Levels, T) ). reachables([]) --> []. reachables([V|Vs]) --> { get_attr(V, edges, Es) }, reachables_(Es, V), reachables(Vs). reachables_([], _) --> []. reachables_([E|Es], V) --> reachable(E, V), reachables_(Es, V). reachable(arc_from(V,F,_), P) --> ( { \+ get_attr(V, parent, _), get_attr(F, flow, Flow), Flow > 0 } -> { put_attr(V, parent, P-augment(F,Flow,-)) }, [V] ; [] ). reachable(arc_to(V,F,C), P) --> ( { \+ get_attr(V, parent, _), get_attr(F, flow, Flow), ( C == inf ; Flow < C )} -> { ( C == inf -> Diff = inf ; Diff is C - Flow ), put_attr(V, parent, P-augment(F,Diff,+)) }, [V] ; [] ). path_minimum([], Min, Min). path_minimum([augment(_,A,_)|As], Min0, Min) :- ( A == inf -> Min1 = Min0 ; Min1 is min(Min0,A) ), path_minimum(As, Min1, Min). augment(Min, augment(F,_,Sign)) :- get_attr(F, flow, Flow0), flow_(Sign, Flow0, Min, Flow), put_attr(F, flow, Flow). flow_(+, F0, A, F) :- F is F0 + A. flow_(-, F0, A, F) :- F is F0 - A. augmenting_path(S, V) --> ( { V == S } -> [] ; { get_attr(V, parent, V1-Augment) }, [Augment], augmenting_path(S, V1) ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% naive_init(Supplies, _, Costs, Alphas, Betas) :- same_length(Supplies, Alphas), maplist(=(0), Alphas), lists_transpose(Costs, TCs), maplist(min_list, TCs, Betas). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% lists_transpose([], []). lists_transpose([L|Ls], Ts) :- foldl(transpose_, L, Ts, [L|Ls], _). transpose_(_, Fs, Lists0, Lists) :- maplist(list_first_rest, Lists0, Fs, Lists). list_first_rest([L|Ls], L, Ls). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TODO: use attributed variables throughout - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ %% transportation(+Supplies, +Demands, +Costs, -Transport) % % Solves a transportation problem. Supplies and Demands must be lists % of non-negative integers. Their respective sums must be equal. Costs % is a list of lists representing the cost matrix, where an entry % (_i_,_j_) denotes the integer cost of transporting one unit from _i_ % to _j_. A transportation plan having minimum cost is computed and % unified with Transport in the form of a list of lists that % represents the transportation matrix, where element (_i_,_j_) % denotes how many units to ship from _i_ to _j_. transportation(Supplies, Demands, Costs, Transport) :- length(Supplies, LAs), length(Demands, LBs), naive_init(Supplies, Demands, Costs, Alphas, Betas), network_head(Supplies, 1, SArcs, []), network_tail(Demands, 1, DArcs, []), numlist(1, LAs, Sources), numlist(1, LBs, Sinks0), maplist(make_sink, Sinks0, Sinks), append(SArcs, DArcs, Torso), alpha_beta(Torso, Sources, Sinks, Costs, Alphas, Betas, Flow), flow_transport(Supplies, 1, Demands, Flow, Transport). flow_transport([], _, _, _, []). flow_transport([_|Rest], N, Demands, Flow, [Line|Lines]) :- transport_line(Demands, N, 1, Flow, Line), N1 is N + 1, flow_transport(Rest, N1, Demands, Flow, Lines). transport_line([], _, _, _, []). transport_line([_|Rest], I, J, Flow, [L|Ls]) :- ( get_assoc(I, Flow, As), get_assoc(p(J), As, arc(I,p(J),F,_)) -> L = F ; L = 0 ), J1 is J + 1, transport_line(Rest, I, J1, Flow, Ls). make_sink(N, p(N)). network_head([], _) --> []. network_head([S|Ss], N) --> [arc(s,N,S)], { N1 is N + 1 }, network_head(Ss, N1). network_tail([], _) --> []. network_tail([D|Ds], N) --> [arc(p(N),t,D)], { N1 is N + 1 }, network_tail(Ds, N1). network_connections([], _, _, _) --> []. network_connections([A|As], Betas, [Cs|Css], N) --> network_connections(Betas, Cs, A, N, 1), { N1 is N + 1 }, network_connections(As, Betas, Css, N1). network_connections([], _, _, _, _) --> []. network_connections([B|Bs], [C|Cs], A, N, PN) --> ( { C =:= A + B } -> [arc(N,p(PN),inf)] ; [] ), { PN1 is PN + 1 }, network_connections(Bs, Cs, A, N, PN1). alpha_beta(Torso, Sources, Sinks, Costs, Alphas, Betas, Flow) :- network_connections(Alphas, Betas, Costs, 1, Cons, []), append(Torso, Cons, Arcs), edmonds_karp(Arcs, MaxFlow), mark_hashes(MaxFlow, MArcs, MRevArcs), all_markable(MArcs, MRevArcs, Markable), mark_unmark(Sources, Markable, MarkSources, UnmarkSources), ( MarkSources == [] -> Flow = MaxFlow ; mark_unmark(Sinks, Markable, MarkSinks0, UnmarkSinks0), maplist(un_p, MarkSinks0, MarkSinks), maplist(un_p, UnmarkSinks0, UnmarkSinks), MarkSources = [FirstSource|_], UnmarkSinks = [FirstSink|_], theta(FirstSource, FirstSink, Costs, Alphas, Betas, TInit), theta(MarkSources, UnmarkSinks, Costs, Alphas, Betas, TInit, Theta), duals_add(MarkSources, Alphas, Theta, Alphas1), duals_add(UnmarkSinks, Betas, Theta, Betas1), Theta1 is -Theta, duals_add(UnmarkSources, Alphas1, Theta1, Alphas2), duals_add(MarkSinks, Betas1, Theta1, Betas2), alpha_beta(Torso, Sources, Sinks, Costs, Alphas2, Betas2, Flow) ). mark_hashes(MaxFlow, Arcs, RevArcs) :- assoc_to_list(MaxFlow, FlowList), maplist(un_arc, FlowList, FlowList1), flatten(FlowList1, FlowList2), empty_assoc(E), mark_arcs(FlowList2, E, Arcs), mark_revarcs(FlowList2, E, RevArcs). un_arc(_-Ls0, Ls) :- assoc_to_list(Ls0, Ls1), maplist(un_arc_, Ls1, Ls). un_arc_(_-Ls, Ls). mark_arcs([], Arcs, Arcs). mark_arcs([arc(From,To,F,C)|Rest], Arcs0, Arcs) :- ( get_assoc(From, Arcs0, As) -> true ; As = [] ), ( C == inf -> As1 = [To|As] ; F < C -> As1 = [To|As] ; As1 = As ), put_assoc(From, Arcs0, As1, Arcs1), mark_arcs(Rest, Arcs1, Arcs). mark_revarcs([], Arcs, Arcs). mark_revarcs([arc(From,To,F,_)|Rest], Arcs0, Arcs) :- ( get_assoc(To, Arcs0, Fs) -> true ; Fs = [] ), ( F > 0 -> Fs1 = [From|Fs] ; Fs1 = Fs ), put_assoc(To, Arcs0, Fs1, Arcs1), mark_revarcs(Rest, Arcs1, Arcs). un_p(p(N), N). duals_add([], Alphas, _, Alphas). duals_add([S|Ss], Alphas0, Theta, Alphas) :- add_to_nth(1, S, Alphas0, Theta, Alphas1), duals_add(Ss, Alphas1, Theta, Alphas). add_to_nth(N, N, [A0|As], Theta, [A|As]) :- !, A is A0 + Theta. add_to_nth(N0, N, [A|As0], Theta, [A|As]) :- N1 is N0 + 1, add_to_nth(N1, N, As0, Theta, As). theta(Source, Sink, Costs, Alphas, Betas, Theta) :- nth1(Source, Costs, Row), nth1(Sink, Row, C), nth1(Source, Alphas, A), nth1(Sink, Betas, B), Theta is (C - A - B) rdiv 2. theta([], _, _, _, _, Theta, Theta). theta([Source|Sources], Sinks, Costs, Alphas, Betas, Theta0, Theta) :- theta_(Sinks, Source, Costs, Alphas, Betas, Theta0, Theta1), theta(Sources, Sinks, Costs, Alphas, Betas, Theta1, Theta). theta_([], _, _, _, _, Theta, Theta). theta_([Sink|Sinks], Source, Costs, Alphas, Betas, Theta0, Theta) :- theta(Source, Sink, Costs, Alphas, Betas, Theta1), Theta2 is min(Theta0, Theta1), theta_(Sinks, Source, Costs, Alphas, Betas, Theta2, Theta). mark_unmark(Nodes, Hash, Mark, Unmark) :- mark_unmark(Nodes, Hash, Mark, [], Unmark, []). mark_unmark([], _, Mark, Mark, Unmark, Unmark). mark_unmark([Node|Nodes], Markable, Mark0, Mark, Unmark0, Unmark) :- ( memberchk(Node, Markable) -> Mark0 = [Node|Mark1], Unmark0 = Unmark1 ; Mark0 = Mark1, Unmark0 = [Node|Unmark1] ), mark_unmark(Nodes, Markable, Mark1, Mark, Unmark1, Unmark). all_markable(Flow, RevArcs, Markable) :- phrase(markable(s, [], _, Flow, RevArcs), Markable). all_markable([], Visited, Visited, _, _) --> []. all_markable([To|Tos], Visited0, Visited, Arcs, RevArcs) --> ( { memberchk(To, Visited0) } -> { Visited0 = Visited1 } ; markable(To, [To|Visited0], Visited1, Arcs, RevArcs) ), all_markable(Tos, Visited1, Visited, Arcs, RevArcs). markable(Current, Visited0, Visited, Arcs, RevArcs) --> { ( Current = p(_) -> ( get_assoc(Current, RevArcs, Fs) -> true ; Fs = [] ) ; ( get_assoc(Current, Arcs, Fs) -> true ; Fs = [] ) ) }, [Current], all_markable(Fs, [Current|Visited0], Visited, Arcs, RevArcs). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - solve(File) -- read input from File. Format (NS = number of sources, ND = number of demands): NS ND S1 S2 S3 ... D1 D2 D3 ... C11 C12 C13 ... C21 C22 C23 ... ... ... ... ... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ input(Ss, Ds, Costs) --> integer(NS), integer(ND), n_integers(NS, Ss), n_integers(ND, Ds), n_kvectors(NS, ND, Costs). n_kvectors(0, _, []) --> !. n_kvectors(N, K, [V|Vs]) --> n_integers(K, V), { N1 is N - 1 }, n_kvectors(N1, K, Vs). n_integers(0, []) --> !. n_integers(N, [I|Is]) --> integer(I), { N1 is N - 1 }, n_integers(N1, Is). number([D|Ds]) --> digit(D), number(Ds). number([D]) --> digit(D). digit(D) --> [D], { between(0'0, 0'9, D) }. integer(N) --> number(Ds), !, ws, { name(N, Ds) }. ws --> [W], { W =< 0' }, !, ws. % closing quote for syntax highlighting: ' ws --> []. solve(File) :- time((phrase_from_file(input(Supplies, Demands, Costs), File), transportation(Supplies, Demands, Costs, Matrix), maplist(print_row, Matrix))), halt. print_row(R) :- maplist(print_row_, R), nl. print_row_(N) :- format("~w ", [N]). % ?- call_residue_vars(transportation([12,7,14], [3,15,9,6], [[20,50,10,60],[70,40,60,30],[40,80,70,40]], Ms), Vs). %@ Ms = [[0, 3, 9, 0], [0, 7, 0, 0], [3, 5, 0, 6]], %@ Vs = []. %?- call_residue_vars(simplex:solve('instance_80_80.txt'), Vs). %?- call_residue_vars(simplex:solve('instance_3_4.txt'), Vs). %?- call_residue_vars(simplex:solve('instance_100_100.txt'), Vs). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% assignment(+Cost, -Assignment) % % Solves a linear assignment problem. Cost is a list of lists % representing the quadratic cost matrix, where element (i,j) denotes % the integer cost of assigning entity $i$ to entity $j$. An % assignment with minimal cost is computed and unified with % Assignment as a list of lists, representing an adjacency matrix. % Assignment problem - for now, reduce to transportation problem assignment(Costs, Assignment) :- length(Costs, LC), length(Supply, LC), all_one(Supply), transportation(Supply, Supply, Costs, Assignment). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Messages - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ :- multifile prolog:message//1. prolog:message(simplex(bounded)) --> ['Using library(simplex) with bounded arithmetic may yield wrong results.'-[]]. warn_if_bounded_arithmetic :- ( current_prolog_flag(bounded, true) -> print_message(warning, simplex(bounded)) ; true ). :- initialization(warn_if_bounded_arithmetic).
josd/eye
eye-wasm/swipl-wasm/home/library/clp/simplex.pl
Perl
mit
53,386
# !!!!!!! DO NOT EDIT THIS FILE !!!!!!! # This file is machine-generated by lib/unicore/mktables from the Unicode # database, Version 6.1.0. Any changes made here will be lost! # !!!!!!! INTERNAL PERL USE ONLY !!!!!!! # This file is for internal use by core Perl only. The format and even the # name or existence of this file are subject to change without notice. Don't # use it directly. return <<'END'; 0009 000A 000C 000D 0020 0085 00A0 1680 180E 2000 200A 2028 2029 202F 205F 3000 END
efortuna/AndroidSDKClone
ndk_experimental/prebuilt/linux-x86_64/lib/perl5/5.16.2/unicore/lib/Perl/SpacePer.pl
Perl
apache-2.0
519
#!/usr/bin/env perl use Dancer; use NCIP::Dancing; dance;
digibib/koha-docker
files/NCIPServer/bin/ncip_dancing.pl
Perl
mit
58
require 'postgresql-lib.pl'; sub cpan_recommended { return ( "DBI", "DBD::Pg" ); }
HasClass0/webmin
postgresql/cpan_modules.pl
Perl
bsd-3-clause
86
package Git::SVN::Editor; use vars qw/@ISA $_rmdir $_cp_similarity $_find_copies_harder $_rename_limit/; use strict; use warnings; use SVN::Core; use SVN::Delta; use Carp qw/croak/; use IO::File; use Git qw/command command_oneline command_noisy command_output_pipe command_input_pipe command_close_pipe command_bidi_pipe command_close_bidi_pipe/; BEGIN { @ISA = qw(SVN::Delta::Editor); } sub new { my ($class, $opts) = @_; foreach (qw/svn_path r ra tree_a tree_b log editor_cb/) { die "$_ required!\n" unless (defined $opts->{$_}); } my $pool = SVN::Pool->new; my $mods = generate_diff($opts->{tree_a}, $opts->{tree_b}); my $types = check_diff_paths($opts->{ra}, $opts->{svn_path}, $opts->{r}, $mods); # $opts->{ra} functions should not be used after this: my @ce = $opts->{ra}->get_commit_editor($opts->{log}, $opts->{editor_cb}, $pool); my $self = SVN::Delta::Editor->new(@ce, $pool); bless $self, $class; foreach (qw/svn_path r tree_a tree_b/) { $self->{$_} = $opts->{$_}; } $self->{url} = $opts->{ra}->{url}; $self->{mods} = $mods; $self->{types} = $types; $self->{pool} = $pool; $self->{bat} = { '' => $self->open_root($self->{r}, $self->{pool}) }; $self->{rm} = { }; $self->{path_prefix} = length $self->{svn_path} ? "$self->{svn_path}/" : ''; $self->{config} = $opts->{config}; $self->{mergeinfo} = $opts->{mergeinfo}; return $self; } sub generate_diff { my ($tree_a, $tree_b) = @_; my @diff_tree = qw(diff-tree -z -r); if ($_cp_similarity) { push @diff_tree, "-C$_cp_similarity"; } else { push @diff_tree, '-C'; } push @diff_tree, '--find-copies-harder' if $_find_copies_harder; push @diff_tree, "-l$_rename_limit" if defined $_rename_limit; push @diff_tree, $tree_a, $tree_b; my ($diff_fh, $ctx) = command_output_pipe(@diff_tree); local $/ = "\0"; my $state = 'meta'; my @mods; while (<$diff_fh>) { chomp $_; # this gets rid of the trailing "\0" if ($state eq 'meta' && /^:(\d{6})\s(\d{6})\s ($::sha1)\s($::sha1)\s ([MTCRAD])\d*$/xo) { push @mods, { mode_a => $1, mode_b => $2, sha1_a => $3, sha1_b => $4, chg => $5 }; if ($5 =~ /^(?:C|R)$/) { $state = 'file_a'; } else { $state = 'file_b'; } } elsif ($state eq 'file_a') { my $x = $mods[$#mods] or croak "Empty array\n"; if ($x->{chg} !~ /^(?:C|R)$/) { croak "Error parsing $_, $x->{chg}\n"; } $x->{file_a} = $_; $state = 'file_b'; } elsif ($state eq 'file_b') { my $x = $mods[$#mods] or croak "Empty array\n"; if (exists $x->{file_a} && $x->{chg} !~ /^(?:C|R)$/) { croak "Error parsing $_, $x->{chg}\n"; } if (!exists $x->{file_a} && $x->{chg} =~ /^(?:C|R)$/) { croak "Error parsing $_, $x->{chg}\n"; } $x->{file_b} = $_; $state = 'meta'; } else { croak "Error parsing $_\n"; } } command_close_pipe($diff_fh, $ctx); \@mods; } sub check_diff_paths { my ($ra, $pfx, $rev, $mods) = @_; my %types; $pfx .= '/' if length $pfx; sub type_diff_paths { my ($ra, $types, $path, $rev) = @_; my @p = split m#/+#, $path; my $c = shift @p; unless (defined $types->{$c}) { $types->{$c} = $ra->check_path($c, $rev); } while (@p) { $c .= '/' . shift @p; next if defined $types->{$c}; $types->{$c} = $ra->check_path($c, $rev); } } foreach my $m (@$mods) { foreach my $f (qw/file_a file_b/) { next unless defined $m->{$f}; my ($dir) = ($m->{$f} =~ m#^(.*?)/?(?:[^/]+)$#); if (length $pfx.$dir && ! defined $types{$dir}) { type_diff_paths($ra, \%types, $pfx.$dir, $rev); } } } \%types; } sub split_path { return ($_[0] =~ m#^(.*?)/?([^/]+)$#); } sub repo_path { my ($self, $path) = @_; if (my $enc = $self->{pathnameencoding}) { require Encode; Encode::from_to($path, $enc, 'UTF-8'); } $self->{path_prefix}.(defined $path ? $path : ''); } sub url_path { my ($self, $path) = @_; if ($self->{url} =~ m#^https?://#) { # characters are taken from subversion/libsvn_subr/path.c $path =~ s#([^~a-zA-Z0-9_./!$&'()*+,-])#sprintf("%%%02X",ord($1))#eg; } $self->{url} . '/' . $self->repo_path($path); } sub rmdirs { my ($self) = @_; my $rm = $self->{rm}; delete $rm->{''}; # we never delete the url we're tracking return unless %$rm; foreach (keys %$rm) { my @d = split m#/#, $_; my $c = shift @d; $rm->{$c} = 1; while (@d) { $c .= '/' . shift @d; $rm->{$c} = 1; } } delete $rm->{$self->{svn_path}}; delete $rm->{''}; # we never delete the url we're tracking return unless %$rm; my ($fh, $ctx) = command_output_pipe(qw/ls-tree --name-only -r -z/, $self->{tree_b}); local $/ = "\0"; while (<$fh>) { chomp; my @dn = split m#/#, $_; while (pop @dn) { delete $rm->{join '/', @dn}; } unless (%$rm) { close $fh; return; } } command_close_pipe($fh, $ctx); my ($r, $p, $bat) = ($self->{r}, $self->{pool}, $self->{bat}); foreach my $d (sort { $b =~ tr#/#/# <=> $a =~ tr#/#/# } keys %$rm) { $self->close_directory($bat->{$d}, $p); my ($dn) = ($d =~ m#^(.*?)/?(?:[^/]+)$#); print "\tD+\t$d/\n" unless $::_q; $self->SUPER::delete_entry($d, $r, $bat->{$dn}, $p); delete $bat->{$d}; } } sub open_or_add_dir { my ($self, $full_path, $baton, $deletions) = @_; my $t = $self->{types}->{$full_path}; if (!defined $t) { die "$full_path not known in r$self->{r} or we have a bug!\n"; } { no warnings 'once'; # SVN::Node::none and SVN::Node::file are used only once, # so we're shutting up Perl's warnings about them. if ($t == $SVN::Node::none || defined($deletions->{$full_path})) { return $self->add_directory($full_path, $baton, undef, -1, $self->{pool}); } elsif ($t == $SVN::Node::dir) { return $self->open_directory($full_path, $baton, $self->{r}, $self->{pool}); } # no warnings 'once' print STDERR "$full_path already exists in repository at ", "r$self->{r} and it is not a directory (", ($t == $SVN::Node::file ? 'file' : 'unknown'),"/$t)\n"; } # no warnings 'once' exit 1; } sub ensure_path { my ($self, $path, $deletions) = @_; my $bat = $self->{bat}; my $repo_path = $self->repo_path($path); return $bat->{''} unless (length $repo_path); my @p = split m#/+#, $repo_path; my $c = shift @p; $bat->{$c} ||= $self->open_or_add_dir($c, $bat->{''}, $deletions); while (@p) { my $c0 = $c; $c .= '/' . shift @p; $bat->{$c} ||= $self->open_or_add_dir($c, $bat->{$c0}, $deletions); } return $bat->{$c}; } # Subroutine to convert a globbing pattern to a regular expression. # From perl cookbook. sub glob2pat { my $globstr = shift; my %patmap = ('*' => '.*', '?' => '.', '[' => '[', ']' => ']'); $globstr =~ s{(.)} { $patmap{$1} || "\Q$1" }ge; return '^' . $globstr . '$'; } sub check_autoprop { my ($self, $pattern, $properties, $file, $fbat) = @_; # Convert the globbing pattern to a regular expression. my $regex = glob2pat($pattern); # Check if the pattern matches the file name. if($file =~ m/($regex)/) { # Parse the list of properties to set. my @props = split(/;/, $properties); foreach my $prop (@props) { # Parse 'name=value' syntax and set the property. if ($prop =~ /([^=]+)=(.*)/) { my ($n,$v) = ($1,$2); for ($n, $v) { s/^\s+//; s/\s+$//; } $self->change_file_prop($fbat, $n, $v); } } } } sub apply_autoprops { my ($self, $file, $fbat) = @_; my $conf_t = ${$self->{config}}{'config'}; no warnings 'once'; # Check [miscellany]/enable-auto-props in svn configuration. if (SVN::_Core::svn_config_get_bool( $conf_t, $SVN::_Core::SVN_CONFIG_SECTION_MISCELLANY, $SVN::_Core::SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS, 0)) { # Auto-props are enabled. Enumerate them to look for matches. my $callback = sub { $self->check_autoprop($_[0], $_[1], $file, $fbat); }; SVN::_Core::svn_config_enumerate( $conf_t, $SVN::_Core::SVN_CONFIG_SECTION_AUTO_PROPS, $callback); } } sub A { my ($self, $m, $deletions) = @_; my ($dir, $file) = split_path($m->{file_b}); my $pbat = $self->ensure_path($dir, $deletions); my $fbat = $self->add_file($self->repo_path($m->{file_b}), $pbat, undef, -1); print "\tA\t$m->{file_b}\n" unless $::_q; $self->apply_autoprops($file, $fbat); $self->chg_file($fbat, $m); $self->close_file($fbat,undef,$self->{pool}); } sub C { my ($self, $m, $deletions) = @_; my ($dir, $file) = split_path($m->{file_b}); my $pbat = $self->ensure_path($dir, $deletions); my $fbat = $self->add_file($self->repo_path($m->{file_b}), $pbat, $self->url_path($m->{file_a}), $self->{r}); print "\tC\t$m->{file_a} => $m->{file_b}\n" unless $::_q; $self->chg_file($fbat, $m); $self->close_file($fbat,undef,$self->{pool}); } sub delete_entry { my ($self, $path, $pbat) = @_; my $rpath = $self->repo_path($path); my ($dir, $file) = split_path($rpath); $self->{rm}->{$dir} = 1; $self->SUPER::delete_entry($rpath, $self->{r}, $pbat, $self->{pool}); } sub R { my ($self, $m, $deletions) = @_; my ($dir, $file) = split_path($m->{file_b}); my $pbat = $self->ensure_path($dir, $deletions); my $fbat = $self->add_file($self->repo_path($m->{file_b}), $pbat, $self->url_path($m->{file_a}), $self->{r}); print "\tR\t$m->{file_a} => $m->{file_b}\n" unless $::_q; $self->apply_autoprops($file, $fbat); $self->chg_file($fbat, $m); $self->close_file($fbat,undef,$self->{pool}); ($dir, $file) = split_path($m->{file_a}); $pbat = $self->ensure_path($dir, $deletions); $self->delete_entry($m->{file_a}, $pbat); } sub M { my ($self, $m, $deletions) = @_; my ($dir, $file) = split_path($m->{file_b}); my $pbat = $self->ensure_path($dir, $deletions); my $fbat = $self->open_file($self->repo_path($m->{file_b}), $pbat,$self->{r},$self->{pool}); print "\t$m->{chg}\t$m->{file_b}\n" unless $::_q; $self->chg_file($fbat, $m); $self->close_file($fbat,undef,$self->{pool}); } sub T { my ($self, $m, $deletions) = @_; # Work around subversion issue 4091: toggling the "is a # symlink" property requires removing and re-adding a # file or else "svn up" on affected clients trips an # assertion and aborts. if (($m->{mode_b} =~ /^120/ && $m->{mode_a} !~ /^120/) || ($m->{mode_b} !~ /^120/ && $m->{mode_a} =~ /^120/)) { $self->D({ mode_a => $m->{mode_a}, mode_b => '000000', sha1_a => $m->{sha1_a}, sha1_b => '0' x 40, chg => 'D', file_b => $m->{file_b} }, $deletions); $self->A({ mode_a => '000000', mode_b => $m->{mode_b}, sha1_a => '0' x 40, sha1_b => $m->{sha1_b}, chg => 'A', file_b => $m->{file_b} }, $deletions); return; } $self->M($m, $deletions); } sub change_file_prop { my ($self, $fbat, $pname, $pval) = @_; $self->SUPER::change_file_prop($fbat, $pname, $pval, $self->{pool}); } sub change_dir_prop { my ($self, $pbat, $pname, $pval) = @_; $self->SUPER::change_dir_prop($pbat, $pname, $pval, $self->{pool}); } sub _chg_file_get_blob ($$$$) { my ($self, $fbat, $m, $which) = @_; my $fh = $::_repository->temp_acquire("git_blob_$which"); if ($m->{"mode_$which"} =~ /^120/) { print $fh 'link ' or croak $!; $self->change_file_prop($fbat,'svn:special','*'); } elsif ($m->{mode_a} =~ /^120/ && $m->{"mode_$which"} !~ /^120/) { $self->change_file_prop($fbat,'svn:special',undef); } my $blob = $m->{"sha1_$which"}; return ($fh,) if ($blob =~ /^0{40}$/); my $size = $::_repository->cat_blob($blob, $fh); croak "Failed to read object $blob" if ($size < 0); $fh->flush == 0 or croak $!; seek $fh, 0, 0 or croak $!; my $exp = ::md5sum($fh); seek $fh, 0, 0 or croak $!; return ($fh, $exp); } sub chg_file { my ($self, $fbat, $m) = @_; if ($m->{mode_b} =~ /755$/ && $m->{mode_a} !~ /755$/) { $self->change_file_prop($fbat,'svn:executable','*'); } elsif ($m->{mode_b} !~ /755$/ && $m->{mode_a} =~ /755$/) { $self->change_file_prop($fbat,'svn:executable',undef); } my ($fh_a, $exp_a) = _chg_file_get_blob $self, $fbat, $m, 'a'; my ($fh_b, $exp_b) = _chg_file_get_blob $self, $fbat, $m, 'b'; my $pool = SVN::Pool->new; my $atd = $self->apply_textdelta($fbat, $exp_a, $pool); if (-s $fh_a) { my $txstream = SVN::TxDelta::new ($fh_a, $fh_b, $pool); my $res = SVN::TxDelta::send_txstream($txstream, @$atd, $pool); if (defined $res) { die "Unexpected result from send_txstream: $res\n", "(SVN::Core::VERSION: $SVN::Core::VERSION)\n"; } } else { my $got = SVN::TxDelta::send_stream($fh_b, @$atd, $pool); die "Checksum mismatch\nexpected: $exp_b\ngot: $got\n" if ($got ne $exp_b); } Git::temp_release($fh_b, 1); Git::temp_release($fh_a, 1); $pool->clear; } sub D { my ($self, $m, $deletions) = @_; my ($dir, $file) = split_path($m->{file_b}); my $pbat = $self->ensure_path($dir, $deletions); print "\tD\t$m->{file_b}\n" unless $::_q; $self->delete_entry($m->{file_b}, $pbat); } sub close_edit { my ($self) = @_; my ($p,$bat) = ($self->{pool}, $self->{bat}); foreach (sort { $b =~ tr#/#/# <=> $a =~ tr#/#/# } keys %$bat) { next if $_ eq ''; $self->close_directory($bat->{$_}, $p); } $self->close_directory($bat->{''}, $p); $self->SUPER::close_edit($p); $p->clear; } sub abort_edit { my ($self) = @_; $self->SUPER::abort_edit($self->{pool}); } sub DESTROY { my $self = shift; $self->SUPER::DESTROY(@_); $self->{pool}->clear; } # this drives the editor sub apply_diff { my ($self) = @_; my $mods = $self->{mods}; my %o = ( D => 0, C => 1, R => 2, A => 3, M => 4, T => 5 ); my %deletions; foreach my $m (@$mods) { if ($m->{chg} eq "D") { $deletions{$m->{file_b}} = 1; } } foreach my $m (sort { $o{$a->{chg}} <=> $o{$b->{chg}} } @$mods) { my $f = $m->{chg}; if (defined $o{$f}) { $self->$f($m, \%deletions); } else { fatal("Invalid change type: $f"); } } if (defined($self->{mergeinfo})) { $self->change_dir_prop($self->{bat}{''}, "svn:mergeinfo", $self->{mergeinfo}); } $self->rmdirs if $_rmdir; if (@$mods == 0 && !defined($self->{mergeinfo})) { $self->abort_edit; } else { $self->close_edit; } return scalar @$mods; } 1; __END__ =head1 NAME Git::SVN::Editor - commit driver for "git svn set-tree" and dcommit =head1 SYNOPSIS use Git::SVN::Editor; use Git::SVN::Ra; my $ra = Git::SVN::Ra->new($url); my %opts = ( r => 19, log => "log message", ra => $ra, config => SVN::Core::config_get_config($svn_config_dir), tree_a => "$commit^", tree_b => "$commit", editor_cb => sub { print "Committed r$_[0]\n"; }, mergeinfo => "/branches/foo:1-10", svn_path => "trunk" ); Git::SVN::Editor->new(\%opts)->apply_diff or print "No changes\n"; my $re = Git::SVN::Editor::glob2pat("trunk/*"); if ($branchname =~ /$re/) { print "matched!\n"; } =head1 DESCRIPTION This module is an implementation detail of the "git svn" command. Do not use it unless you are developing git-svn. This module adapts the C<SVN::Delta::Editor> object returned by C<SVN::Delta::get_commit_editor> and drives it to convey the difference between two git tree objects to a remote Subversion repository. The interface will change as git-svn evolves. =head1 DEPENDENCIES Subversion perl bindings, the core L<Carp> and L<IO::File> modules, and git's L<Git> helper module. C<Git::SVN::Editor> has not been tested using callers other than B<git-svn> itself. =head1 SEE ALSO L<SVN::Delta>, L<Git::SVN::Fetcher>. =head1 INCOMPATIBILITIES None reported. =head1 BUGS None.
pniebla/test-repo-console
svn/git-1.8.3.3.tar/git-1.8.3.3/git-1.8.3.3/perl/Git/SVN/Editor.pm
Perl
mit
15,413
package # Date::Manip::Offset::off312; # 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:43 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 = '-04:35:08'; %Offset = ( 0 => [ 'america/thule', ], ); 1;
jkb78/extrajnm
local/lib/perl5/Date/Manip/Offset/off312.pm
Perl
mit
852
#!/usr/bin/perl -w #Author: Pengcheng Yang #Email: yangpc@mail.biols.ac.cn use strict; use Getopt::Long; use File::Basename qw(basename dirname); my $usage= "\n$0 --inf \t<str>\tinput file --informt \t<str>\tinput file format: \t\twego: geneID<tb>GOID<tb>GOID<tb>... \t\tthree: geneID<tb>ClassID<tb>ClassDesc \t\tgaf: GO annotation file format --outDir \t<str>\toutput directory \n"; my($inf,$informt,$outDir); GetOptions( "inf:s"=>\$inf, "informt:s"=>\$informt, "outDir:s"=>\$outDir ); die $usage if !defined $informt; my $inf_base = basename $inf; my(@info,%gen2set,%set2gen,%setDes,$rscp); if($informt eq "wego"){ $rscp = qq# date() library(GO.db) goterm <- as.list(GOTERM) tmp <- scan("$inf",what="character",sep="\\n") g2go <- sapply(tmp,function(x){ x1 <- strsplit(x,"\\t")[[1]] x1[2:length(x1)] }) names(g2go) <- sapply(tmp,function(x) strsplit(x,"\\t")[[1]][1]) go2g <- tapply(rep(names(g2go),sapply(g2go,length)),unlist(g2go),as.character) go2g <- go2g[intersect(names(go2g),names(goterm))] gmt <- sapply(names(go2g),function(x) paste(x,Term(goterm[[x]]),paste(go2g[[x]],collapse="\\t"),sep="\\t")) write.table(gmt,file="$outDir/$inf_base.gmt",quote=FALSE,row.names=FALSE,col.names=FALSE) date() q('no') #; open O,">","$outDir/$inf_base.R"; print O $rscp; close O; `R CMD BATCH $outDir/$inf_base.R $outDir/$inf_base.Rout`; } if($informt eq "three"){ $rscp=qq# date() options(stringsAsFactors=FALSE) tmp <- read.table("$inf",sep="\\t",check.names=FALSE,quote="") tmp <- tmp[grep("IPR",tmp[,2]),] set2g <- tapply(tmp[,1],tmp[,2],as.character) setDes <- unique(paste(tmp[,2],tmp[,3],sep="\\t")) names(setDes) <- sapply(setDes,function(x) strsplit(x,"\\t")[[1]][1]) setDes <- sapply(setDes,function(x) gsub("IPR[0-9]+\\t","",x)) gmt <- sapply(names(set2g),function(x) paste(x,setDes[x],paste(set2g[[x]],collapse="\\t"),sep="\\t")) write.table(gmt,file="$outDir/$inf_base.gmt",col.names=FALSE,row.names=FALSE,quote=FALSE) date() q('no') #; open O,">","$outDir/$inf_base.R"; print O $rscp; close O; `R CMD BATCH $outDir/$inf_base.R $outDir/$inf_base.Rout`; } if($informt eq "gaf"){ my(%set2gene,%seqDes); open I,$inf; while(<I>){ chomp;@info=split /\t/; next if /^!/; $set2gene{$info[3]}{$info[1]}++; $seqDes{$info[3]}++; } close I; open O,">","$outDir/$inf_base.gmt"; close O; }
pengchy/EACO
bin/xxx2gmt.pl
Perl
mit
2,348
#!/usr/bin/perl # made by: KorG use strict; use v5.18; use warnings; no warnings 'experimental'; use utf8; binmode STDOUT, ':utf8'; use lib '.'; use gen; # Read zero (main) level into memory from STDIN gen->read_level(); # Switch to the first level gen->level(1); # Get random angle for the city being built my $city_angle = int rand 4; # Create a new level #TODO generate random city size gen->recreate_level_unsafe($city_angle % 2 ? (40, 20) : (20, 40)); # Generate city ground gen->generate_blurred_area(1, ',', 0.45); # Use ',' as free space too gen->free_regex('[.,"^]'); #TODO Generate this building dynamically my $building; $building = [ map { [ split // ] } ( " 1 ", "##+##", "#___#", "#___#", "#####", ) ]; # Overlay the building with rotation gen->overlay_somehow($building); #TODO Make a loop to build multiple buildings. use eval or die # Switch back to the main level gen->level(0); # Reset free space regex gen->free_regex(); # Overlay generated city over it gen->overlay_somehow(gen->get_level_ref(1), {rotate => [$city_angle]}); # Print the level gen->print_level(0);
zhmylove/itmmorgue
scripts/gen_city.pl
Perl
mit
1,135
#!/usr/bin/perl -w ################################################################################ ## ## FILE: extract_stable.pl ## ## CVS: $Id: extract_stable.pl,v 1.2 2003-06-04 22:36:16 scottl Exp $ ## ## DESCRIPTION: Perl script to exctract, convert and print a list of Stable URLs ## found searching all html files below the $SRC directory ## ################################################################################ use strict; ## VARIABLES ## ############### my $dirname = "./science"; # directory to start looking for html files in. my $file; # current file to be looked at. my $line; # current line being inspected my $regexp = "(.*)(Stable URL: .*)(links.jstor.org.*)(</nobr>.*)"; #go through each file in the current directory opendir(DIR, $dirname) or die "can't opendir $dirname: $!"; while (defined($file = readdir(DIR))) { #open and parse the file open(FILE, "$dirname/$file") or die "can't open file $dirname/$file: $!"; #parse the file looking for $regexp foreach $line (<FILE>) { if ($line =~ $regexp) { #$line contains $regexp, substitute it using $replace as a guide $_ = $line; s/$regexp/http:\/\/$3/; ## \3 refers to the 3rd portion of the file. print STDOUT $_; } } close(FILE); } closedir(DIR);
scttl/jtag
scripts/extract_stable.pl
Perl
mit
1,343