summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormertz2000-12-21 16:41:01 +0000
committermertz2000-12-21 16:41:01 +0000
commit746bb1727708a4956b3832bdd254d4f99303764a (patch)
tree040eb8551b834eaa053ae97c7fabf1007b8feb68
parentd828648644ee3f4bec0ba5d559848c4858c33700 (diff)
downloadivy-perl-746bb1727708a4956b3832bdd254d4f99303764a.zip
ivy-perl-746bb1727708a4956b3832bdd254d4f99303764a.tar.gz
ivy-perl-746bb1727708a4956b3832bdd254d4f99303764a.tar.bz2
ivy-perl-746bb1727708a4956b3832bdd254d4f99303764a.tar.xz
- This version is compatible again with version 3 of Ivy.
Thats means it can be used again without ivy object. This has been documented in the man pages. However it is preferable to create Ivy objects. - \s and ^\s in regexp are now correctly expanded as tab and blank characters - regular expressions are now case-insensitive (the same as ivy-c!) Of course, case of parameters transmitted on the bus are preserved! - an implementation of ivyprobe is given as an example and as a test tool /usr/bin/ivyprobe.pl -h for more infos. - when :port is used as a domain/port ivy-perl now really do connect to the 127:port bus. - man pages have been enhanced. Some features not yet documented are now (mainly sendDirect / bindDirect / fileEvent). - the stop method works now also with applications written with the C version of ivy. However the hack may not be the good solution!
-rw-r--r--debian/changelog21
-rwxr-xr-xexample/ivyprobe.pl220
2 files changed, 191 insertions, 50 deletions
diff --git a/debian/changelog b/debian/changelog
index f28d8bf..907e917 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,24 @@
+ivy-perl (4.6) unstable; urgency=low
+
+ * This version is compatible again with version 3 of Ivy.
+ Thats means it can be used again without ivy object.
+ This has been documented in the man pages. However it is preferable
+ to create Ivy objects.
+ * \s and ^\s in regexp are now correctly expanded as tab and
+ blank characters
+ * regular expressions are now case-insensitive (the same as ivy-c!)
+ Of course, case of parameters transmitted on the bus are preserved!
+ * an implementation of ivyprobe is given as an example and as a test tool
+ /usr/bin/ivyprobe.pl -h for more infos.
+ * when :port is used as a domain/port ivy-perl now really do connect
+ to the 127:port bus.
+ * man pages have been enhanced. Some features not yet documented
+ are now (mainly sendDirect / bindDirect / fileEvent).
+ * the stop method works now also with applications written
+ with the C version of ivy. However the hack may not be the good solution!
+
+ -- Christophe MERTZ <mertz@cena.fr> Wed, 20 Dec 2000 11:02:00 +0100
+
ivy-perl (4.3) unstable; urgency=low
* Typo correction in _removeFileDescriptor causing infinite loop.
diff --git a/example/ivyprobe.pl b/example/ivyprobe.pl
index d12a2c2..bb25a14 100755
--- a/example/ivyprobe.pl
+++ b/example/ivyprobe.pl
@@ -1,10 +1,25 @@
#!/usr/bin/perl -w
-
+#
# $Source$
# $Revision$
#
# $Author$
# $Date$
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU GPL General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA,
+# or refer to http://www.gnu.org/copyleft/gpl.html
+#
use strict;
use Ivy;
@@ -14,24 +29,14 @@ use Tk;
my $bus;
-my %connected_applis;
-# a hash code each key is a connected appli_name and the value the number of
-# applis with this name.
+# for each application gives the number of running instances
+my %connected_applications;
+# for each couple appli:host gives the number of application running on host
+my %where_applications;
&check_options;
-
-sub check_options {
- # on traite la ligne de commande
- my ($opt_help, $opt_gf);
- GetOptions("help" => \$opt_help,
- "b" => \$bus,
- );
-
- &usage if ($opt_help && $opt_help);
-}
-
if (defined $bus) {
Ivy->init (-ivyBus => $bus,
-appName => "IVYPROBE.PL",
@@ -52,6 +57,7 @@ my $Ivyobj = Ivy->new(-statusFunc => \&statusFunc,
foreach my $regexp (@ARGV) {
print "binding to $regexp\n";
+ if ($regexp =~ /'(.*)'/) { $regexp = $1; }
$Ivyobj->bindRegexp($regexp, [ "unused", \&callback] );
}
@@ -68,34 +74,23 @@ Ivy->fileEvent($IN, \&cb);
Ivy->mainLoop;
+
+# this function has 3 additionnal parameters till Ivy Version 4.6
+# and now getting the new/dying applications is straightforward.
+# The first 3 parameters are kept only for compatibility!
sub statusFunc {
- my ($ref_ready, $ref_nonReady, $ref_hashReady) = @_;
-# print "App: $appname\tStatus: $status\taddr: $addr\n";
-# print "statusFunc!!\n";
-# print "ready : ", join (' ', @$ref_ready), "\n";
-# print "NonReady : ", join (' ', @$ref_nonReady), "\n";
-# print "hashReady : ", join (' ', %$ref_hashReady), "\n";
-# print "connected_applis : ", join (' ', %connected_applis), "\n";
- while (my ($appli, $nb) = each (%$ref_hashReady)) {
- if (!defined $connected_applis{$appli} || $connected_applis{$appli} < $nb) {
- print "$appli connected\n";
- }
- elsif ($connected_applis{$appli} > $nb) {
- print "$appli disconnected\n";
- }
- delete $connected_applis{$appli};
+ my ($ref_ready, $ref_nonReady, $ref_hashReady, $appname, $status, $host) = @_;
+
+ if ($status eq "new") {
+ print "$appname connected from $host\n";
+ $where_applications{"$appname:$host"}++;
}
- while (my ($appli, $nb) = each (%connected_applis)) {
- print "$appli disconnected\n";
+ elsif ($status eq "died") {
+ print "$appname disconnected from $host\n";
+ $where_applications{"$appname:$host"}--;
}
-
- undef %connected_applis;
- while (my ($appli, $nb) = each (%$ref_hashReady)) {
- if (defined $nb && $nb > 0) {
- $connected_applis{$appli} = $nb;
- }
- }
-
+
+ %connected_applications = %$ref_hashReady;
}
@@ -154,6 +149,34 @@ sub interpret_line {
$Ivyobj->sendDirectMsgs($appname, $id, $data);
return 0;
}
+
+ if ($str =~ /^.who\s*$/) {
+ print "Apps:";
+ foreach my $app (sort keys %connected_applications) {
+ for (my $i=0; $i<$connected_applications{$app} ; $i++) {
+ print " $app";
+ }
+ }
+ print "\n";
+ return 0;
+ }
+
+ if ($str =~ /^.where\s+(\S+)$/) {
+ my $appli = $1;
+ my $found = 0;
+ foreach my $app_host (keys %where_applications) {
+ my ($app,$host) = $app_host =~ /(.+):(.*)/ ;
+ if ($app eq $appli) {
+ for (my $i=0; $i<$where_applications{$app_host}; $i++) {
+ print "Application $app on $host\n";
+ $found = 1;
+ }
+ }
+ }
+ print "No Application $appli\n" unless ($found);
+ return 0;
+ }
+
print "bad command: .help for list of commands\n";
return 0;
@@ -171,22 +194,35 @@ sub directCallback {
my (@param) = @_;
my $paramString = "";
- if (scalar @param) { $paramString = join (" ", @param); }
- print "directMessage sent '", $paramString, "'\n";
+ if (scalar @param) { $paramString = join ("|", @param); }
+ print "directMessage received '", $paramString, "'\n";
}
+
+sub check_options {
+ # on traite la ligne de commande
+ my ($opt_help, $opt_gf);
+ GetOptions("help" => \$opt_help,
+ "b:s" => \$bus,
+ );
+
+ &usage if ($opt_help && $opt_help);
+}
+
+
sub usage {
- print "ivyprobe [ -b <network>:<port> ] [-h] 'regexp'\n";
- print " ivyprobe is a simple test application for\n";
- print " based a a similar appplication available with ivy-c\n";
- print " It waits for messages on the bus and commands\n";
- print " issued on the command line.\n";
+ print "ivyprobe [-h] [ -b <network>:<port> ] ['regexp']*\n";
+ print " ivyprobe is a simple test application for the ivy-perl library\n";
+ print " Its is based on a similar appplication available with ivy-c\n";
+ print " It waits for messages on the bus, messages writtten on the command line\n";
+ print " or commands issued on the comnand line\n";
print " a help for the command line is available through\n";
print " the command .help or .h\n";
print " -h print this help\n";
print " -b <network>:<port>\n";
print " to defined the network adress and the port number\n";
print " defaulted to 127:2010\n";
+ exit;
}
@@ -194,11 +230,95 @@ sub line_command_usage {
print "Commands list:\n";
print " .h[elp] - this help\n";
print " .q[uit] - terminate this application\n";
- print " .die appname - send die msg to appname\n";
- print " .d[irect] appname id args - send direct msg to appname\n";
- print " .where appname - on which host is appname\n";
print " .b[ind] regexp - add a msg to receive\n";
+ print " .die appname - send die msg to appname\n";
print " .db[ind] id - add a direct msg to receive\n";
+ print " .d[irect] appname id args - send direct msg to appname\n";
+ print " .where appname - on which host is/are appname\n";
print " .who - who is on the bus\n";
}
+
+__END__
+
+
+=head1 NAME
+
+ivyprobe.pl - simple application to test ivy, to test other ivy-application or the perl ivy implementation.
+
+=head1 SYNOPSIS
+
+ivyprobe.pl [-h] [-b <network>:<port> ] ['regexp']*
+
+=head1 DESCRIPTION
+
+B<ivyprobe> connects to the bus and offers a simple text interface to receive and send messages, and to subscribe to messages. It is very similar to the C version named ivyprobe.
+
+If regexps are given as parameters it subscribes to theses regexp.
+
+To send a message, just type this message on the command line. It will be send to all applications who subscribe to this message. The number of application to which the message is sent is displayed.
+
+The user can input the following commands:
+
+=over
+
+=item .h[elp]
+
+to get the list of available commands and short explanations
+
+=item .q[uit]
+
+to terminate the application.
+
+=item .b[ind] regexp
+
+to add a subscription to messages matching the regexp.
+
+=item .die appname
+
+to send a die msg to appname. This application will stop.
+
+=item .db[ind] id
+
+to add a direct msg of type id to receive
+
+=item .d[irect] appname id string
+
+to send a direct msg to appname. The message type is indicated by id
+
+=item .where appname
+
+To get the host on which appname is/are running
+
+=item .who
+
+to get the list of all connected applications
+
+=item .h[elp]
+
+to get the list of available commands and short explanations
+
+=back
+
+=head1 BUGS
+
+It is currently not possible to send a message which begin with a dot. It will be interpreted as a command (usually unknown!)
+
+No other know bugs at this time. Report them to author.
+
+
+=head1 SEE ALSO
+
+ivy-perl(1), perl(1)
+
+=head1 AUTHORS
+
+Christophe Mertz <mertz@cena.fr>
+
+=head1 COPYRIGHT
+
+CENA (C) 2000
+
+=head1 HISTORY
+
+=cut