add beginnings of a route find command.
[spider.git] / perl / DXProtout.pm
index 856a60bb7ad081f0a48de49798f5b39f8c5890d6..e42c4ef2bde1df0a7e9d983683d482a1f84fdbd7 100644 (file)
@@ -20,10 +20,7 @@ use DXDebug;
 use strict;
 
 use vars qw($VERSION $BRANCH);
-$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
-$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/  || (0,0));
-$main::build += $VERSION;
-$main::branch += $BRANCH;
+($VERSION, $BRANCH) = dxver(q$Revision$);
 
 use vars qw($sentencelth);
 
@@ -38,7 +35,7 @@ sub pc10
 {
        my ($from, $to, $via, $text, $origin) = @_;
        my ($user1, $user2);
-       if ($via && $via ne $to) {
+       if ($via && $via ne $to && $via ne '*') {
                $user1 = $via;
                $user2 = $to;
        } else {
@@ -123,7 +120,7 @@ sub pc17
 # Request init string
 sub pc18
 {
-       my $flags = " pc";
+       my $flags = " pc9x";
        $flags .= " xml" if DXXml::available(); 
        return "PC18^DXSpider Version: $main::version Build: $main::build$flags^$DXProt::myprot_version^";
 }
@@ -377,61 +374,81 @@ sub pc85
 # spider route broadcasts
 #
 
-my $_last_time;
-my $_last_occurs;
 
-sub _gen_time
+sub _gen_pc92
 {
-       if (!$_last_time || $_last_time != $main::systime) {
-               $_last_time = $main::systime;
-               $_last_occurs = 0;
-               return $_last_time;
-       } else {
-               $_last_occurs++;
-               return "$_last_time:$_last_occurs";
+       my $sort = shift;
+       my $ext = shift;
+       my $s = "PC92^$main::mycall^" . gen_pc9x_t() . "^$sort";
+       for (@_) {
+               $s .= "^" . _encode_pc92_call($_, $ext);
        }
+       return $s . '^H99^';
 }
 
-sub _gen_pc92
+sub gen_pc92_with_time
 {
+       my $call = shift;
        my $sort = shift;
-       my $s = "PC92^$sort^" . _gen_time;
+       my $t = shift;
+       my $ext = 1;
+       my $s = "PC92^$call^$t^$sort";
        for (@_) {
-               my $flag = 0;
-               my $call = $_->call; 
-               my $extra = '';
-               if ($_->isa('Route::Node')) {
-                       $flag = 4;
-                       if ($call ne $main::mycall && DXChannel::get($call)) {
-                               $flag += 2;
-                       }
-                       if ($sort eq 'C') {
-                               $extra .= ':' . ($_->version || '') if $_->build;
-                               $extra .= ':' . $_->build if $_->build;
-                       }
-               }
-               $flag += $_->here ? 1 : 0;
-               $s .= "^$flag$call$extra";
+               $s .= "^" . _encode_pc92_call($_, $ext);
        }
-       return $s . '^H99';
+       return $s . '^H99^';
 }
 
 # add a local one
 sub pc92a
 {
-       return _gen_pc92('A', @_);
+       return _gen_pc92('A', 0, @_);
 }
 
 # delete a local one
 sub pc92d
 {
-       return _gen_pc92('D', @_);
+       return _gen_pc92('D', 0, @_);
 }
 
 # send a config
 sub pc92c
 {
-       return _gen_pc92('C', @_);
+       return _gen_pc92('C', 1, @_);
+}
+
+# send a 'find' message
+sub pc92f
+{
+       my $target = shift;
+       my $from = shift;
+       return "PC92^$main::mycall^" . gen_pc9x_t() . "^F^$from^$target^H99^"
+}
+
+# send a 'reply' message
+sub pc92r
+{
+       my $to = shift;
+       my $target = shift;
+       my $flag = shift;
+       my $ms = shift;
+       return "PC92^$main::mycall^" . gen_pc9x_t() . "^R^$to^$target^$flag^$ms^H99^"
+}
+
+sub pc93
+{
+       my $to = shift;                         # *, callsign, chat group name, sysop
+       my $from = shift;                       # from user callsign
+       my $via = shift || '*';                 # *, node call
+       my $line = shift;                       # the text
+       my $origin = shift;                     # this will be present on proxying from PC10
+       
+       $line = unpad($line);
+       $line =~ s/\^/\\5E/g;           # remove any ^ characters
+       my $s = "PC93^$main::mycall^" . gen_pc9x_t() . "^$to^$from^$via^$line";
+       $s .= "^$origin" if $origin;
+       $s .= "^H99^";
+       return $s;
 }
 
 1;