/usr/share/perl5/POE/Component/IKC/Specifier.pm is in libpoe-component-ikc-perl 0.2302-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | package POE::Component::IKC::Specifier;
############################################################
# $Id: Specifier.pm 819 2011-08-27 01:57:36Z fil $
#
# Copyright 1999-2011 Philip Gwyn. All rights reserved.
# This program is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself.
#
# Contributed portions of IKC may be copyright by their respective
# contributors.
use strict;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
use Carp;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw( specifier_parse specifier_name specifier_part);
$VERSION = '0.2302';
sub DEBUG { 0 }
#----------------------------------------------------
# Turn an specifier into a hash ref
sub specifier_parse ($)
{
my($specifier)=@_;
return if not $specifier;
my $kernelRE = q((?:\*) |
(?:[-. \w]+) |
(?:[a-zA-Z0-9][-.a-zA-Z0-9]+:\d+) |
(?:unix:[-.\w]+(?::\d+-\d+)?)
);
unless(ref $specifier) {
if($specifier=~m(^poe:
(?:
(//)
($kernelRE)?
)?
(?:
(/)
([- \w]+)
)?
(?:
(/)?
([- \w]*)
)?
(?: \x3f
(\w+)
)?
$)x) {
$specifier={kernel=>$2, session=>$4, state=>$6};
$specifier->{args}=$7 if $7;
}
elsif( $specifier =~ m(^ (?:(?://)($kernelRE)/)?
(?:([- \w]+)/)?
(?:([- \w]+))?
(?: \x3f (\w+) )?
$)x ) {
$specifier = { kernel=>$1, session=>$2, state=>$3 };
$specifier->{args} = $4 if $4;
}
else {
return;
}
}
elsif('HASH' ne ref $specifier) {
# carp "Why is specifier a ", ref $specifier;
return;
}
$specifier->{kernel}||='';
$specifier->{session}||='';
$specifier->{state}||='';
return $specifier;
}
sub specifier_part ($$)
{
my($specifier, $part)=@_;
return if not $specifier;
$specifier="poe://$specifier" unless ref $specifier or $specifier=~/^poe:/;
$specifier=specifier_parse $specifier;
return if not $specifier;
return $specifier->{$part};
}
#----------------------------------------------------
# Turn an specifier into a string
sub specifier_name ($)
{
my($specifier)=@_;
return $specifier unless(ref $specifier);
if(ref($specifier) eq 'ARRAY')
{
$specifier={kernel=>'',
session=>$specifier->[0],
state=>$specifier->[1],
};
}
my $name='poe:';
if($specifier->{kernel})
{
$name.='//';
$name.=$specifier->{kernel};
}
if($specifier->{session})
{
$name.='/'.$specifier->{session};
}
$name.="/$specifier->{state}" if $specifier->{state};
return $name;
}
1;
__END__
=head1 NAME
POE::Component::IKC::Specifier - IKC event specifer
=head1 SYNOPSIS
use POE;
use POE::Component::IKC::Specifier;
$state=specifier_parse('poe://*/timeserver/connect');
print 'The foreign state is '.specifier_name($state);
=head1 DESCRIPTION
This is a helper module that encapsulates POE IKC specifiers. An IKC
specifier is a way of designating either a kernel, a session or a state
within a IKC cluster.
IKC specifiers have the folloing format :
poe:://kernel/session/state
B<kernel> may a kernel name, a kernel ID, blank (for local kernel), a
'*' (all known foreign kernels) or host:port (not currently supported).
B<session> may be any session alias that has been published by the foreign
kernel.
B<state> is a state that has been published by a foreign session.
Examples :
=over 4
=item C<poe://Pulse/timeserver/connect>
State 'connect' in session 'timeserver' on kernel 'Pulse'.
=item C<poe:/timeserver/connect>
State 'connect' in session 'timeserver' on the local kernel.
=item C<poe://*/timeserver/connect>
State 'connect' in session 'timeserver' on any known foreign kernel.
=item C<poe://Billy/bob/>
Session 'bob' on foreign kernel 'Billy'.
=back
=head1 EXPORTED FUNCTIONS
=head2 C<specifier_parse($spec)>
Turn a specifier into the internal representation (hash ref). Returns
B<undef()> if the specifier wasn't valid.
print Dumper specifer_parse('poe://Pulse/timeserver/time');
would print
$VAR1 = {
kernel => 'Pulse',
session => 'timeserver',
state => 'time',
};
B<Note> : the internal representation might very well change some day.
=head2 C<specifier_name($spec)>
Turns a specifier into a string.
=head1 BUGS
=head1 AUTHOR
Philip Gwyn, <perl-ikc at pied.nu>
=head1 COPYRIGHT AND LICENSE
Copyright 1999-2011 by Philip Gwyn. All rights reserved.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
See L<http://www.perl.com/language/misc/Artistic.html>
=head1 SEE ALSO
L<POE>, L<POE::Component::IKC::Responder>
=cut
|