disabled
  "   lY>e8	1hh      disabled
  #   l=J2B P"iLZ7343 W    TZif2                            
      :ˉϏЁuX       MDT MST MWT       TZif2                                  ^:ˉϏЁuX     LMT MDT MST MWT         
MST7
  "   lY>e8Ю1hh      disabled
  0   	li~mJi@
q)F_ub&=LV[( ?     	#   -*- perl -*-
#
#
#   PlRPC - Perl RPC, package for writing simple, RPC like clients and
#       servers
#
#
#   Copyright (c) 1997,1998  Jochen Wiedmann
#
#   You may distribute under the terms of either the GNU General Public
#   License or the Artistic License, as specified in the Perl README file.
#
#   Author: Jochen Wiedmann
#           Email: jochen.wiedmann at freenet.de
#
#

use strict;

require Net::Daemon;
require RPC::PlServer::Comm;


package RPC::PlServer;

@RPC::PlServer::ISA = qw(Net::Daemon);
$RPC::PlServer::VERSION = '0.2020';


############################################################################
#
#   Name:    Version (Class method)
#
#   Purpose: Returns version string
#
#   Inputs:  $class - This class
#
#   Result:  Version string; suitable for printed by "--version"
#
############################################################################

sub Version ($) {
    "RPC::PlServer application, Copyright (C) 1997, 1998, Jochen Wiedmann";
}


############################################################################
#
#   Name:    Options (Class method)
#
#   Purpose: Returns a hash ref of command line options
#
#   Inputs:  $class - This class
#
#   Result:  Options array; any option is represented by a hash ref;
#            used keys are 'template', a string suitable for describing
#            the option to Getopt::Long::GetOptions and 'description',
#            a string for the Usage message
#
############################################################################

sub Options ($) {
    my $options = shift->SUPER::Options();
    $options->{'maxmessage'} =
	{ 'template' => 'maxmessage=i',
	  'description' =>  '--maxmessage <size>           '
	  . 'Set max message size to <size> (Default 65535).'
	};
    $options->{'compression'} =
	{ 'template' => 'compression=s',
	  'description' =>  '--compression <type>           '
	  . 'Set compression type to off (default) or gzip.'
	};
    $options;
}


############################################################################
#
#   Name:    AcceptApplication, AcceptVersion, AcceptUser
#            (Instance methods)
#
#   Purpose: Called for authentication purposes; these three in common
#            are replacing Net::Daemon's Accept().
#
#   Inputs:  $self - Server instance
#            $app - Application name
#            $version - Version number
#            $user, $password - User name and password
#
#   Result:  TRUE, if the client has successfully authorized, FALSE
#            otherwise. The AcceptUser method (being called as the
#            last) may additionally return an array ref as a TRUE
#            value: This is treated as welcome message.
#
############################################################################

sub AcceptApplication ($$) {
    my $self = shift; my $app = shift;
    $self->Debug("Client requests application $app");
    UNIVERSAL::isa($self, $app);
}

sub AcceptVersion ($$) {
    my $self = shift; my $version = shift;
    $self->Debug("Client requests version $version");
    no strict 'refs';
    my $myversion = ${ref($self) . "::VERSION"};
    ($version <= $myversion) ? 1 : 0;
}

sub AcceptUser ($$$) {
    my $self = shift; my $user = shift; my $password = shift;

    my $client = $self->{'client'};
    return 1 unless $client->{'users'};
    my $users = $client->{'users'};
    foreach my $u (@$users) {
	my $au;
	if (ref($u)) {
	    $au = $u;
	    $u = defined($u->{'name'}) ? $u->{'name'} : '';
	}
	if ($u eq $use