libfrontier-rpc-perl-0.07b4.orig/0000755000175000017500000000000010025477501016345 5ustar srzsrz00000000000000libfrontier-rpc-perl-0.07b4.orig/COPYING0000644000175000017500000000025107271071010017370 0ustar srzsrz00000000000000Copyright (C) 1998-2001 Ken MacLeod. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. libfrontier-rpc-perl-0.07b4.orig/ChangeLog0000644000175000017500000001063007522623757020135 0ustar srzsrz000000000000002002-08-02 Ivan Kohler * lib/Frontier/RPC2.pm: added repr subroutine for String datatype so that an explicity-specified String type encodes < > & and " * MANIFEST: added docs/make-rel 2002-08-02 Ken MacLeod * docs/make-rel: added * README: changed mirror location to SourceForge; added notes for Apache::XMLRPC and Frontier::Responder. 2001-04-25 Ken MacLeod * lib/Frontier/Daemon.pm (new): return $self; submitted by Aaron E. Ross 2001-04-23 Ken MacLeod * docs/changes.xml, docs/changes.xsl: added * COPYING: updated to clarify "same terms as Perl" * README: note that some required modules are now included in Perl distribution. 2001-04-09 Ken MacLeod * lib/Frontier/RPC2.pm: change all $self to $expat in XML::Parser callbacks; noted by Terry Triplett 2001-01-26 Ken MacLeod * MANIFEST: add lib/Frontier/Responder.pm 2000-11-08 Ken MacLeod * lib/Frontier/RPC2.pm: for base64(), note that user must use MIME::Base64; noted by Marc Singer * lib/Frontier/Responder.pm: added; submitted by Joe Johnston * lib/Apache/XMLRPC.pm: added POD and tweaks; submitted by Tim Peoples 2000-09-27 Ken MacLeod * lib/Frontier/Daemon.pm (new): add use_objects * lib/Frontier/RPC2.pm (decode): copy use_objects to new parser (die, init, start, end, char, final): change $self to $expat to make clear what's going on (_item): serialize blessed array and hash references as and s 2000-09-26 Ken MacLeod * lib/Frontier/RPC2.pm (end): support as a 'use_objects' value 2000-06-01 Ken MacLeod * examples/validator1-daemon.pl: added * lib/Frontier/RPC2.pm (boolean, double, int): added type checking submitted by Nick Bauman * README: added contributors * lib/Apache/XMLRPC.pm: added 1999-11-20 Ken MacLeod * examples/cli-xml-rpc.pl, examples/example-cli-input: added * lib/Frontier/Client.pm, lib/Frontier/RPC2.pm: added Integer, Float, and String objects; merge code from Nick Bauman 1999-10-11 Ken MacLeod * lib/Frontier/RPC2.pm (new): define encoding_ as "" if not present 1999-10-07 Ken MacLeod * lib/Frontier/RPC2.pm (end): zero `may_get_cdata' flag after use 1999-09-02 Ken MacLeod * lib/Frontier/Client.pm (new): support key, value pairs or hash add encoding, debug, and proxy options * lib/Frontier/RPC2.pm (new): support key, value pairs or hash add encoding option 1999-05-24 Ken MacLeod * lib/Frontier/RPC2.pm (start): fix defaulting to string 1999-04-13 Ken MacLeod * Makefile.PL: add a PREREQ_PM for XML::Parser * lib/Frontier/RPC2.pm (serve): fix reused name in same scope (_scalar): use different technique for checking for int, double, string * lib/Frontier/Client.pm (call): use $1 instead of \1 1999-02-02 Ken MacLeod * lib/Frontier/RPC2.pm: fixed nested hashes by relayering encoding (_item): added (_params): added (base64, boolean, date_time): added shortcuts 1999-01-28 Ken MacLeod * lib/Frontier/Daemon.pm (serve): moved to RPC2.pm 1999-01-25 Ken MacLeod * lib/Frontier/Client.pm: added boolean, date, and base64 shortcuts * lib/Frontier/RPC2.pm: added boolean, date, and base64 data types 1999-01-19 Ken MacLeod * README: updated required Perl modules, mailing lists, added QUICK USAGE GUIDE * examples/states-client.pl: added * lib/Frontier/RPC2.pm (decode): changed to newer XML::Parser call style (die): user newer XML::Parser line numbering (start): call Frontier::RPC2::die because $self is now an Expat instance 1998-07-27 Ken MacLeod * lib/Frontier/RPC2.pm (start, end): add tag for named params * lib/Frontier/Daemon.pm (new): add Content-Type header * lib/Frontier/Client.pm (new): change `host', `port' to `url' (new): add Content-Type header * examples/rpc-client.pl: change HOST[:PORT] to URL use `dumpvar' to dump result 1998-04-13 Ken MacLeod * release 0.01 libfrontier-rpc-perl-0.07b4.orig/Changes0000644000175000017500000000706007522550351017646 0ustar srzsrz00000000000000Revision history for Perl extension Frontier::RPC. `*' indicates backward incompatible changes 0.07 - Added prototype 'docs/changes.xml' and XSLT stylesheet, stylesheet contributed by Laurent Bossavit, based on changes.xml from Apache XML's Cocoon - Corrected COPYING to be "same terms as Perl" (ie. Artistic and GPL) - Added Frontier::Responder CGI responder, contributed by Joe Johnston - Merged POD for Apache::XMLRPC, contributed by Tim Peoples - Added examples/validator1-daemon.pl validation suite - Added Apache::XMLRPC, contributed by Ed Hill - Added type checking for newly created special data types, contributed by Nick Bauman - serialize blessed array and hash references as and s, suggested by John Posner - Frontier::Daemon now supports use_objects, suggested by John Posner - Added docs/make-rel to create releases from CVS - fixes - create an Integer special object for s (was just s), reported by John Posner - use_objects wasn't working, reported by John Posner - an explicity-specified String type now correctly encodes < > & and " 0.06 Sat Nov 20 17:09:40 CST 1999 - Nick Bauman sent in a patch to add Integer, Float, and String objects to avoid implicit conversion errors. - add encoding options to Frontier::Client and Frontier::RPC2; suggested by Skip Montanaro - "Jon Frisby" sent in a patch to add a proxy option to Frontier::Client - add debug option to Frontier::Client - support new options in rpc-client.pl example - support key, value pairs or hashes for options - add example script for using XML-RPC over pipes and as a CGI; CGI changes were provided by Jon Frisby - fixes - values without types are now parsed properly, reported by Sean Brown - corrupted results when untyped values appear in s; reported by Bas A. Schulte - Frontier::RPC2: fix uninitialized use of `encoding_'; also reported by Bas A. Schulte Note: the error: Modification of a read-only value attempted at /usr/lib/perl5/site_perl/XML/Parser/Expat.pm line 126. was a bug in the XML::Parser module that is fixed in the latest version of XML::Parser. 0.05 Tue Apr 13 14:58:00 CDT 1999 - add a prerequisit for XML::Parser in Makefile.PL - fixes - use a new test for encoding ints, doubles, and strings fixing a bug where some strings were encoded as - warnings from perl -w 0.04 Tue Feb 2 09:45:17 CST 1999 - add shortcuts for boolean, date, and base64 types to Frontier::RPC2 too - fixes - fix encoding of nested hashes - fix decoding of long strings 0.03 Thu Jan 28 15:10:35 CST 1999 - Move server handler from Frontier::Daemon to Frontier::RPC2 so it can be used from other transports - Frontier::Client: Added support for boolean, double, date, and base64 data types 0.02 Tue Jan 19 13:08:05 CST 1999 - updated README, added a QUICK USAGE GUIDE, updated required Perl modules, and updated mailing list info - added a simpler client demo, `examples/states-client.pl' - upgraded to newer version of XML::Parser API * rpc-client.pl, Frontier::Client.pm: use full URL instead of HOST and PORT - recognize tags for parameters - fixes - add Content-Type: text/xml header 0.01 Mon Apr 13 10:57:31 1998 - original version; created by h2xs 1.18 libfrontier-rpc-perl-0.07b4.orig/Frontier-RPC-0.07b4.spec0000644000175000017500000000246507522624106022255 0ustar srzsrz00000000000000Summary: Perl module for RPC over XML Name: Frontier-RPC Version: 0.07b4 Release: 1 Source: ftp://ftp.uu.net/vendor/bitsko/gdo/Frontier-RPC-0.07b4.tar.gz Copyright: distributable Group: Networking/Utilities URL: http://www.bitsko.slc.ut.us/ Packager: ken@bitsko.slc.ut.us (Ken MacLeod) BuildRoot: /tmp/Frontier-RPC # # $Id: Frontier-RPC.spec,v 1.2 2000/06/01 15:32:06 kmacleod Exp $ # %description Frontier::RPC implements UserLand Software's XML RPC (Remote Procedure Calls using Extensible Markup Language). Frontier::RPC includes both a client module for making requests to a server and a daemon module for implementing servers. Frontier::RPC uses RPC2 format messages. %prep %setup perl Makefile.PL INSTALLDIRS=perl %build make %install make PREFIX="${RPM_ROOT_DIR}/usr" pure_install DOCDIR="${RPM_ROOT_DIR}/usr/doc/Frontier-RPC-0.07b4-1" mkdir -p "$DOCDIR/examples" for ii in README COPYING Changes test.pl examples/*; do cp $ii "$DOCDIR/$ii" chmod 644 "$DOCDIR/$ii" done %files /usr/doc/Frontier-RPC-0.07b4-1 /usr/lib/perl5/Frontier/Client.pm /usr/lib/perl5/Frontier/Daemon.pm /usr/lib/perl5/Frontier/RPC2.pm /usr/lib/perl5/Apache/XMLRPC.pm /usr/lib/perl5/man/man3/Frontier::Client.3 /usr/lib/perl5/man/man3/Frontier::Daemon.3 /usr/lib/perl5/man/man3/Frontier::RPC2.3 /usr/lib/perl5/man/man3/Apache::XMLRPC.3 libfrontier-rpc-perl-0.07b4.orig/Frontier-RPC.spec0000644000175000017500000000250107115500766021437 0ustar srzsrz00000000000000Summary: Perl module for RPC over XML Name: Frontier-RPC Version: @VERSION@ Release: 1 Source: ftp://ftp.uu.net/vendor/bitsko/gdo/Frontier-RPC-@VERSION@.tar.gz Copyright: distributable Group: Networking/Utilities URL: http://www.bitsko.slc.ut.us/ Packager: ken@bitsko.slc.ut.us (Ken MacLeod) BuildRoot: /tmp/Frontier-RPC # # $Id: Frontier-RPC.spec,v 1.2 2000/06/01 15:32:06 kmacleod Exp $ # %description Frontier::RPC implements UserLand Software's XML RPC (Remote Procedure Calls using Extensible Markup Language). Frontier::RPC includes both a client module for making requests to a server and a daemon module for implementing servers. Frontier::RPC uses RPC2 format messages. %prep %setup perl Makefile.PL INSTALLDIRS=perl %build make %install make PREFIX="${RPM_ROOT_DIR}/usr" pure_install DOCDIR="${RPM_ROOT_DIR}/usr/doc/Frontier-RPC-@VERSION@-1" mkdir -p "$DOCDIR/examples" for ii in README COPYING Changes test.pl examples/*; do cp $ii "$DOCDIR/$ii" chmod 644 "$DOCDIR/$ii" done %files /usr/doc/Frontier-RPC-@VERSION@-1 /usr/lib/perl5/Frontier/Client.pm /usr/lib/perl5/Frontier/Daemon.pm /usr/lib/perl5/Frontier/RPC2.pm /usr/lib/perl5/Apache/XMLRPC.pm /usr/lib/perl5/man/man3/Frontier::Client.3 /usr/lib/perl5/man/man3/Frontier::Daemon.3 /usr/lib/perl5/man/man3/Frontier::RPC2.3 /usr/lib/perl5/man/man3/Apache::XMLRPC.3 libfrontier-rpc-perl-0.07b4.orig/MANIFEST0000644000175000017500000000064707522624106017510 0ustar srzsrz00000000000000COPYING ChangeLog Changes Frontier-RPC.spec Frontier-RPC-0.07b4.spec MANIFEST Makefile.PL README docs/changes.xml docs/changes.xsl docs/make-rel examples/cli-xml-rpc.pl examples/example-cli-input examples/rpc-client.pl examples/states-client.pl examples/states-daemon.pl examples/validator1-daemon.pl lib/Apache/XMLRPC.pm lib/Frontier/Client.pm lib/Frontier/RPC2.pm lib/Frontier/Daemon.pm lib/Frontier/Responder.pm test.pl libfrontier-rpc-perl-0.07b4.orig/Makefile.PL0000644000175000017500000000107107522624106020321 0ustar srzsrz00000000000000# # Copyright (C) 1998 Ken MacLeod # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. # # $Id: Makefile.PL,v 1.2 1999/04/13 19:43:46 kmacleod Exp $ # $VERSION = '0.07b4'; use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( 'NAME' => 'Frontier::RPC', 'VERSION_FROM' => 'Makefile.PL', 'PREREQ_PM' => { XML::Parser => '2.19' }, 'dist' => {'COMPRESS' => 'gzip', 'SUFFIX' => '.gz'}, ); libfrontier-rpc-perl-0.07b4.orig/README0000644000175000017500000001014007522516472017232 0ustar srzsrz00000000000000 $Id: README,v 1.11 2002/08/02 14:54:50 kmacleod Exp $ Frontier::RPC A Perl 5 module for performing Remote Procedure Calls using Extensible Markup Language Ken MacLeod ken@bitsko.slc.ut.us With contributions from Nick Bauman, Laurent Bossavit, Sean Brown, Jon Frisby, Ed Hill, Joe Johnston, Skip Montanaro, Tim Peoples, John Posner, Aaron Ross, Bas Schulte, Marc Singer, and Terry Triplett INTRODUCTION Frontier::RPC implements UserLand Software's XML RPC (Remote Procedure Calls using Extensible Markup Language). Frontier::RPC includes both a client module for making requests to a server and several server modules for implementing servers using CGI, Apache, and standalone with HTTP::Daemon. See the file Changes for user-visible changes. See the `examples' directory for an example of using Frontier::RPC. See the ``XML RPC: Home Page'' for more information on XML RPC. Newer versions of this module can be found on CPAN or at . Questions can be directed to the discussion board on XML-RPC.com or to the XML-RPC mailing list. To join the XML-RPC mailing list visit . Copyright (C) 1998-2002 Ken MacLeod Frontier::RPC is distributed under the same terms as Perl. OVERVIEW RPC client connections are made by creating instances of Frontier::Client objects that record the server name, and then issuing `call' requests that send a method name and parameters to the server. RPC daemons are mini-HTTP servers (using HTTP::Daemon from the `libwww' Perl module). Daemons are created by first defining the procedures you want to make available to RPC and then passing a list of those procedures as you create the Frontier::Daemon object. The Frontier::RPC2 module implements the encoding and decoding of XML RPC requests using the XML::Parser Perl module. Apache::XMLRPC serves XML-RPC requests from Apache's mod_perl. Frontier::Responder serves XML-RPC requests as a CGI script. QUICK USAGE GUIDE Frontier::RPC converts between XML-RPC s and Perl hashes, s and Perl arrays, and all others XML-RPC types to Perl scalars. To call an RPC server, use Frontier::Client: use Frontier::Client; $server = Frontier::Client->new(url => $url); $result = $server->call($method, @args); $url is the URL of the XML-RPC server, like `http://betty.userland.com/RPC2', $method is the XML-RPC procedure name to call, and @args is a list of hashes, arrays, or scalars to pass to the procedure. See `examples/states-client.pl' for an example of an XML-RPC client. To create an XML-RPC server, use Frontier::Daemon. Frontier::Daemon is a subclass of HTTP::Daemon, so takes all the options that HTTP::Daemon takes for setting up a server, such as the port number. In addition, Frontier::Daemon takes a `methods' option that is a hash containing the RPC procedure names and references to Perl subroutines: use Frontier::Daemon; Frontier::Daemon->new(methods => { 'rpcName' => &sub_name, }); The subroutines get called with the XML-RPC parameters as hashes, arrays, and scalars. See `examples/states-daemon.pl' for an example of an XML-RPC server. INSTALLATION Frontier::RPC requires the following Perl modules from CPAN, if not already included in your installed Perl: Data-Dumper (in the Data directory) MIME-Base64 (in the MIME directory) MD5 (in the MD5 directory) HTML-Tagset (in the HTML directory) HTML-Parser (in the HTML directory) URI (in the URI directory) libnet (in the Net directory) libwww-perl (in the HTTP directory) XML-Parser (in the XML directory) Frontier::RPC installs as a standard Perl module perl Makefile.PL make make test make install libfrontier-rpc-perl-0.07b4.orig/docs/0000755000175000017500000000000010025477501017275 5ustar srzsrz00000000000000libfrontier-rpc-perl-0.07b4.orig/docs/changes.xml0000644000175000017500000000422307271076667021451 0ustar srzsrz00000000000000 Added prototype 'docs/changes.xml'. Corrected COPYING to be "same terms as Perl" (ie. Artistic and GPL). Added Frontier::Responder CGI responder. Merged POD for Apache::XMLRPC. Added 'examples/validator1-daemon.pl' validation suite. Added Apache::XMLRPC. Added type checking for newly created special data types. Serialize blessed array and hash references as <array> and <struct>s. Frontier::Daemon now supports use_objects. Create an Integer special object for <int>s (was just <i4>s). 'use_objects' wasn't working. libfrontier-rpc-perl-0.07b4.orig/docs/changes.xsl0000644000175000017500000000243307271076667021460 0ustar srzsrz00000000000000

-Fixes:
-
libfrontier-rpc-perl-0.07b4.orig/docs/make-rel0000755000175000017500000000647007522516472020740 0ustar srzsrz00000000000000#! /bin/sh # # NAME # make-rel -- make a software release # # SYNOPSIS usage="make-rel SYMBOLIC_TAG MODULE" # # DESCRIPTION # # `make-rel' exports MODULE from CVS using SYMBOLIC_TAG and # creates a distribution from it. # # `make-rel' can tell the difference between `autoconf' style # packages, Perl, and Python packages and create them accordingly. # # For `autoconf' packages, `make-rel' edits the SYMBOLIC_TAG into # `configure.in', runs `autoconf', `./configure', and then # performs a `make dist'. # # For Perl packages, `make-rel' edits the SYMBOLIC_TAG into the # file identified in `Makefile.PL' as the `VERSION_FROM' file, # runs `perl Makefile.pl' and `make dist'. # # For Python packages, `make-rel' edits the SYMBOLIC_TAG into # `setup.py'. # # SYMBOLIC_TAGs of the form ``r([0-9]+)m([0-9]+)(.*)'' are # reformatted to ``\1.\2\3'' to translate between CVS/RCSs # requirement against using `.' in a tag name. For example, a # symbolic tag `r0m1b1' is reformatted to `0.1b1'. # # The leading `r' of a SYMBOLIC_TAG is removed. Underscores (`_') # are translated to periods (`.'). # # $Id: make-rel,v 1.1 2002/08/02 14:54:50 kmacleod Exp $ # AUTOCONF="/usr/bin/autoconf" GREP="/usr/bin/grep" PERL="/usr/bin/perl" AWK="/usr/bin/awk" CVS="/usr/bin/cvs" PWD_CMD="/bin/pwd" SED="/bin/sed" TR="/usr/bin/tr" if [ $# != 2 ]; then echo "$usage" exit 0 fi SYMBOLIC_TAG="$1" MODULE="$2" set -e set -x original_dir="`$PWD_CMD`" release="`echo \"$SYMBOLIC_TAG\" | $SED -e 's/r\([0-9]\{1,\}\)m\([0-9]\{1,\}\)\(.*\)/\1.\2\3/'`" release="`echo \"$release\" | $SED -e 's/^r//' | $TR '_' '.'`" mkdir /tmp/dist-$$ cd /tmp/dist-$$ $CVS export -r $SYMBOLIC_TAG -d dist $MODULE cd dist if [ -f configure.in ]; then mv configure.in .. # edit the SYMBOLIC_TAG into `configure.in', translating to a # ``cleaner'' release number $SED <../configure.in >configure.in \ -e 's/^VERSION=.*$/VERSION='"$release"'/' echo "$release" >.release $AUTOCONF ./configure make dist cd .. elif [ -f Makefile.PL ]; then perl <<'EOF' use ExtUtils::Manifest; ($missfile, $missentry) = ExtUtils::Manifest::fullcheck; die "make-rel: release does not check against manifest\n" if ($#{$missfile} != -1 || $#{$missentry} != -1); EOF if [ $? != 0 ]; then exit 1; fi VERSION_FROM="`$SED -n -e \"/VERSION_FROM/s/.*'\(.*\)',/\1/p\" Makefile.PL`" mv $VERSION_FROM .. $SED <../`basename $VERSION_FROM` >$VERSION_FROM \ -e '/VERSION = /s/0\.00/'"$release"'/' for ii in `find . -name \*.pm`; do mv $ii .. $SED <../`basename $ii` >$ii \ -e '/VERSION = /s/0\.00/'"$release"'/' done if [ -f $MODULE.spec ]; then $SED <$MODULE.spec >$MODULE-$release.spec \ -e 's/@VERSION@/'"$release"'/g' mv MANIFEST .. $SED <../MANIFEST >MANIFEST \ -e "/^$MODULE.spec$/a\\ $MODULE-$release.spec " fi perl Makefile.PL make dist mv $MODULE-$release.tar.gz .. cd .. elif [ -f setup.py ]; then mv setup.py .. $SED <../setup.py >setup.py \ -e '/version = /s/0\.0\.0/'"$release"'/' python setup.py sdist mv dist/$MODULE-$release.tar.gz .. cd .. else echo "Unknown package type" cd .. rm -rf dist-$$ exit 1 fi chmod a-w *.tar.gz mv *.tar.gz $original_dir cd .. rm -rf dist-$$ libfrontier-rpc-perl-0.07b4.orig/examples/0000755000175000017500000000000010025477501020163 5ustar srzsrz00000000000000libfrontier-rpc-perl-0.07b4.orig/examples/cli-xml-rpc.pl0000644000175000017500000000613607015634441022660 0ustar srzsrz00000000000000# This perl script is an example of using XML-RPC as an interface to # local processes through a pipe. You can pass RPC requests on # standard input to this script and receive RPC responses on standard # out. # # That's not all! This script is also an example of running multiple # requests in the same connection (pipe). # # But wait, there's more! This script can also be used as an XML-RPC # CGI by removing the `print "\n--]]><<\n";' line near the end of the # script. # # The file `example-cli-input' is a sample input file for this script. # # $Id: cli-xml-rpc.pl,v 1.1 1999/11/21 00:13:21 kmacleod Exp $ # use Frontier::RPC2; # this flag is set by the `done' RPC when called $done = 0; ### ### The following is the meat of this server, copied from the ### Frontier::RPC `states-daemon.pl' example script ### @states = (qw/Alabama Alaska Arizona Arkansas California Colorado Connecticut Delaware Florida Georgia Hawaii Idaho Illinois Indiana Iowa Kansas Kentucky Louisiana Maine Maryland Massachusetts Michigan Minnesota Mississippi Missouri Montana Nebraska Nevada/, 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', qw/Ohio Oklahoma Oregon Pennsylvania/, 'Rhode Island', 'South Carolina', 'South Dakota', qw/Tennessee Texas Utah Vermont Virginia Washington/, 'West Virginia', 'Wisconsin', 'Wyoming'); sub get_state_name { my $state_num = shift; return $states[$state_num - 1]; } sub get_state_list { my $num_list = shift; my ($state_num, @state_list); foreach $state_num (@$num_list) { push @state_list, $states[$state_num - 1]; } return join(',', @state_list); } sub get_state_struct { my $struct = shift; my ($state_num, @state_list); foreach $state_num (values %$struct) { push @state_list, $states[$state_num - 1]; } return join(',', @state_list); } sub echo { return [@_]; } sub done { $done = 1; } ### ### This is the main loop that reads one RPC call from standard input, ### services it, and then returns the resulting XML. ### ### XML-RPC requests and replies are terminated by a single line ### containing the sequence: ### ### --]]><< ### ### This sequence of characters is not allowed in ordinary XML. ### $| = 1; # Perl magic to use unbuffered output on standard output $xml_rpc_server = Frontier::RPC2->new; # create a list of the methods to be served $methods = { 'examples.getStateName' => \&get_state_name, 'examples.getStateList' => \&get_state_list, 'examples.getStateStruct' => \&get_state_struct, 'echo' => \&echo, 'done' => \&done, }; while ( !$done ) { # read one line from standard input, until it is the seperator @xml_fragment = (); while ( ($line = <>) && ($line !~ /^--\]\]><<$/) ) { push @xml_fragment, $line; } # end of input if nothing pushed on @xml_fragment last if $#xml_fragment == -1; # serve and print the result print $xml_rpc_server->serve ( join ('', @xml_fragment), $methods ); # Remove the following line to use this script as a CGI print "\n--]]><<\n"; } libfrontier-rpc-perl-0.07b4.orig/examples/example-cli-input0000644000175000017500000000027307015634441023450 0ustar srzsrz00000000000000 examples.getStateName 41 --]]><< libfrontier-rpc-perl-0.07b4.orig/examples/rpc-client.pl0000644000175000017500000000426706763555461022611 0ustar srzsrz00000000000000# # Copyright (C) 1998 Ken MacLeod # See the file COPYING for distribution terms. # # $Id: rpc-client.pl,v 1.3 1999/09/02 20:16:49 kmacleod Exp $ # =head1 NAME rpc-client -- example XML RPC client =head1 SYNOPSIS rpc-client [--debug] [--encoding ENCODING] [--proxy PROXY] \ URL METHOD ["ARGLIST"] =head1 DESCRIPTION `C' exercises an XML RPC server. I is the URL of the RPC server to contact, including a path if necessary, like `C'. I is the procedure to call on the remote server. `C<"I">' is the argument list to be sent to the remote server. I may include Perl array and hash constructors and should always be quoted. The result returned from the XML RPC server is displayed using Perl's `dumpvar.pl' utility, showing the internal structure of the objects returned from the server. The `C<--debug>' option will cause the client to print the XML request sent to and XML response received from the server. The `C<--encoding>' option will supply an alternate encoding for the XML request. The default is none, which uses XML 1.0's default of UTF-8. The `C<--proxy>' option is a URL of an HTTP proxy to pass the request through. =head1 EXAMPLES rpc-client http://betty.userland.com/RPC2 examples.getStateName "41" rpc-client http://betty.userland.com/RPC2 \ examples.getStateList "[12, 28, 33, 39, 46]" rpc-client http://betty.userland.com/RPC2 \ examples.getStateStruct "{state1 => 18, state2 => 27, state3 => 48}" =cut use Frontier::Client; use Getopt::Long; my $debug = 0; my $encoding = undef; my $proxy = undef; GetOptions( 'debug' => \$debug, 'encoding=s' => \$encoding, 'proxy=s' => \$proxy ); die "usage: rpc-client URL METHOD [\"ARGLIST\"]\n" if ($#ARGV != 1 && $#ARGV != 2); my $url = shift @ARGV; my $method = shift @ARGV; my $arglist = shift @ARGV; $server = Frontier::Client->new( 'url' => $url, 'debug' => $debug, 'encoding' => $encoding, 'proxy' => $proxy ); my @arglist; eval "\@arglist = ($arglist)"; $result = $server->call ($method, @arglist); require 'dumpvar.pl'; dumpvar ('main', 'result'); libfrontier-rpc-perl-0.07b4.orig/examples/states-client.pl0000644000175000017500000000154706651154641023315 0ustar srzsrz00000000000000# # Copyright (C) 1999 Ken MacLeod # See the file COPYING for distribution terms. # # $Id: states-client.pl,v 1.1 1999/01/19 19:14:41 kmacleod Exp $ # require 'dumpvar.pl'; # used to dump results use Frontier::Client; $url = 'http://betty.userland.com/RPC2'; # this client will accept a URL on the command line if it's given if ($#ARGV > -1) { $url = $ARGV[0]; } $server = Frontier::Client->new( url => $url ); printf "Calling examples.getStateName\n"; $result = $server->call('examples.getStateName', 41); dumpvar ('main', 'result'); printf "Calling examples.getStateList\n"; $result = $server->call('examples.getStateList', [12, 28, 33, 39, 46]); dumpvar ('main', 'result'); printf "Calling examples.getStateStruct\n"; $result = $server->call('examples.getStateStruct', { state1 => 18, state2 => 27, state3 => 48 }); dumpvar ('main', 'result'); libfrontier-rpc-perl-0.07b4.orig/examples/states-daemon.pl0000644000175000017500000000300106514556430023265 0ustar srzsrz00000000000000# # Copyright (C) 1998 Ken MacLeod # See the file COPYING for distribution terms. # # $Id: states-daemon.pl,v 1.1.1.1 1998/04/14 03:50:48 ken Exp $ # use Frontier::Daemon; @states = (qw/Alabama Alaska Arizona Arkansas California Colorado Connecticut Delaware Florida Georgia Hawaii Idaho Illinois Indiana Iowa Kansas Kentucky Louisiana Maine Maryland Massachusetts Michigan Minnesota Mississippi Missouri Montana Nebraska Nevada/, 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', qw/Ohio Oklahoma Oregon Pennsylvania/, 'Rhode Island', 'South Carolina', 'South Dakota', qw/Tennessee Texas Utah Vermont Virginia Washington/, 'West Virginia', 'Wisconsin', 'Wyoming'); sub get_state_name { my $state_num = shift; return $states[$state_num - 1]; } sub get_state_list { my $num_list = shift; my ($state_num, @state_list); foreach $state_num (@$num_list) { push @state_list, $states[$state_num - 1]; } return join(',', @state_list); } sub get_state_struct { my $struct = shift; my ($state_num, @state_list); foreach $state_num (values %$struct) { push @state_list, $states[$state_num - 1]; } return join(',', @state_list); } sub echo { return [@_]; } new Frontier::Daemon LocalPort => 8000, methods => { 'examples.getStateName' => \&get_state_name, 'examples.getStateList' => \&get_state_list, 'examples.getStateStruct' => \&get_state_struct, 'echo' => \&echo, }; libfrontier-rpc-perl-0.07b4.orig/examples/validator1-daemon.pl0000644000175000017500000000275507115506427024046 0ustar srzsrz00000000000000# # Copyright (C) 2000 Ken MacLeod # See the file COPYING for distribution terms. # # $Id: validator1-daemon.pl,v 1.4 2000/06/01 16:19:35 kmacleod Exp $ # use Frontier::Daemon; sub arrayOfStructsTest { my $array = shift; my $curly_sum = 0; for my $struct (@$array) { $curly_sum += $struct->{'curly'}; } return $curly_sum; } sub easyStructTest { my $struct = shift; return $struct->{'moe'} + $struct->{'larry'} + $struct->{'curly'}; } sub echoStructTest { return shift; } sub manyTypesTest { return [@_]; } sub moderateSizeArrayCheck { my $array = shift; return join('', $array->[0], $array->[-1]); } sub nestedStructTest { my $calendar = shift; my $april_1_2000 = $calendar->{'2000'}{'04'}{'01'}; return ($april_1_2000->{'moe'} + $april_1_2000->{'larry'} + $april_1_2000->{'curly'}); } sub simpleStructReturnTest { my $number = shift; return { times10 => $number * 10, times100 => $number * 100, times1000 => $number * 1000 }; } new Frontier::Daemon LocalPort => 8000, methods => { 'validator1.arrayOfStructsTest' => \&arrayOfStructsTest, 'validator1.easyStructTest' => \&easyStructTest, 'validator1.echoStructTest' => \&echoStructTest, 'validator1.manyTypesTest' => \&manyTypesTest, 'validator1.moderateSizeArrayCheck' => \&moderateSizeArrayCheck, 'validator1.nestedStructTest' => \&nestedStructTest, 'validator1.simpleStructReturnTest' => \&simpleStructReturnTest, }; libfrontier-rpc-perl-0.07b4.orig/lib/0000755000175000017500000000000010025477501017113 5ustar srzsrz00000000000000libfrontier-rpc-perl-0.07b4.orig/lib/Apache/0000755000175000017500000000000010025477501020274 5ustar srzsrz00000000000000libfrontier-rpc-perl-0.07b4.orig/lib/Apache/XMLRPC.pm0000644000175000017500000000716307522624106021651 0ustar srzsrz00000000000000# # Module Copyright (C) 2000 Ed Hill # Documentation Copyright (C) 2000 Tim Peoples # # Apache::XMLRPC is free software; you can redistribute it # and/or modify it under the same terms as Perl itself. # # $Id: XMLRPC.pm,v 1.2 2000/11/09 01:36:34 kmacleod Exp $ # package Apache::XMLRPC; use Apache::Constants qw(:common); use Frontier::RPC2; sub handler { my $r = shift; my $conf = $r->server_root_relative( $r->dir_config( "XMLRPC_Config" ) ); if( -f $conf ) { unless( $rt = do $conf ) { die "Couldn\'t parse conf file ($conf): $@\n" if $@; die "Couldn\'t compile conf file ($conf): $!\n" unless defined $rt; die "Couldn\'t run conf file ($conf)\n" unless $rt; } } my $decoder = Frontier::RPC2->new(); my $content; $r->read( $content, $r->header_in( 'Content-length' ) ); my $answer = $decoder->serve( $content, $Apache::XMLRPC::map ); $r->send_http_header(); $r->print($answer); return OK; } 1; __END__ =head1 NAME Apache::XMLRPC - serve XML-RPC requests from Apache =head1 SYNOPSIS ## ## Directives for your Apache config file. ## SetHandler perl-script PerlHandler Apache::XMLRPC PerlSetVar XMLRPC_Config /usr/local/apache/xml-rpc/services ## ## In the 'services' file referenced above by 'XMLRPC_Config' ## sub foo { ... } sub bar { ... } $map = { foo => \&foo, bar => \&bar, }; 1; =head1 DESCRIPTION I serves Userland XML-RPC requests from Apache/mod_perl using the Frontier::RPC2 module. Configuring Apache::XMLRPC to work under mod_perl is a two step process. First, you must declare a CLocationE> directive in your Apache configuration file which tells Apache to use the content handler found in the Apache::XMLRPC module and defines a variable which tells the module where to find your services. Then, you must define the services. =head2 Apache Configuration Apache configuration is as simple as the CLocationE> directive shown in the synopsis above. Any directive allowed by Apache inside a CLocationE> block is allowed here, but the three lines shown above are required. Pay close attention to the 'PerlSetVar XMLRPC_Config ...' line as this is where you tell Apache where to find your services. This file may reside anywhere accessable by Apache. =head2 Defining Services To actually define the XML-RPC routines that will be served, they I reside in the file referenced by the 'PerlSetVar XMLRPC_Config ...' directive in the Apache configuration file. In this file you may place as many Perl subroutines as you like, but only those which are explicitly published will be available to your XML-RPC clients. To I a subroutine, it must be included in the hash reference named C<$map> (the hash reference I have this name as this is the variable that the I passes to I to actually service each request) The hash reference I be defined in this C file. The keys of the hash are the service names visible to the XML-RPC clients while the hash values are references to the subroutines you wish to make public. There is no requirement that the published service names match those of their associated subroutines, but it does make administration a little easier. =head1 SEE ALSO perl(1), Frontier::RPC2(3) Ehttp://www.scripting.com/frontier5/xml/code/rpc.htmlE =head1 AUTHOR Ed Hill Eed-hill@uiowa.eduE is the original author. Tim Peoples Etep@colltech.comE added a few tweaks and all the documenation. libfrontier-rpc-perl-0.07b4.orig/lib/Frontier/0000755000175000017500000000000010025477501020703 5ustar srzsrz00000000000000libfrontier-rpc-perl-0.07b4.orig/lib/Frontier/Client.pm0000644000175000017500000001507607522624106022473 0ustar srzsrz00000000000000# # Copyright (C) 1998 Ken MacLeod # Frontier::Client is free software; you can redistribute it # and/or modify it under the same terms as Perl itself. # # $Id: Client.pm,v 1.8 2001/10/03 01:30:54 kmacleod Exp $ # # NOTE: see Net::pRPC for a Perl RPC implementation use strict; package Frontier::Client; use Frontier::RPC2; use LWP::UserAgent; use HTTP::Request; use vars qw{$AUTOLOAD}; sub new { my $class = shift; my $self = ($#_ == 0) ? { %{ (shift) } } : { @_ }; bless $self, $class; die "Frontier::RPC::new: no url defined\n" if !defined $self->{'url'}; $self->{'ua'} = LWP::UserAgent->new; $self->{'ua'}->proxy('http', $self->{'proxy'}) if(defined $self->{'proxy'}); $self->{'rq'} = HTTP::Request->new (POST => $self->{'url'}); $self->{'rq'}->header('Content-Type' => 'text/xml'); my @options; if(defined $self->{'encoding'}) { push @options, 'encoding' => $self->{'encoding'}; } if (defined $self->{'use_objects'} && $self->{'use_objects'}) { push @options, 'use_objects' => $self->{'use_objects'}; } $self->{'enc'} = Frontier::RPC2->new(@options); return $self; } sub call { my $self = shift; my $text = $self->{'enc'}->encode_call(@_); if ($self->{'debug'}) { print "---- request ----\n"; print $text; } $self->{'rq'}->content($text); my $response = $self->{'ua'}->request($self->{'rq'}); if (!$response->is_success) { die $response->status_line . "\n"; } my $content = $response->content; if ($self->{'debug'}) { print "---- response ----\n"; print $content; } my $result = $self->{'enc'}->decode($content); if ($result->{'type'} eq 'fault') { die "Fault returned from XML RPC Server, fault code " . $result->{'value'}[0]{'faultCode'} . ": " . $result->{'value'}[0]{'faultString'} . "\n"; } return $result->{'value'}[0]; } # shortcuts sub base64 { my $self = shift; return Frontier::RPC2::Base64->new(@_); } sub boolean { my $self = shift; return Frontier::RPC2::Boolean->new(@_); } sub double { my $self = shift; return Frontier::RPC2::Double->new(@_); } sub int { my $self = shift; return Frontier::RPC2::Integer->new(@_); } sub string { my $self = shift; return Frontier::RPC2::String->new(@_); } sub date_time { my $self = shift; return Frontier::RPC2::DateTime::ISO8601->new(@_); } # something like this could be used to get an effect of # # $server->examples_getStateName(41) # # instead of # # $server->call('examples.getStateName', 41) # # for Frontier's # # [server].examples.getStateName 41 # # sub AUTOLOAD { # my ($pkg, $method) = ($AUTOLOAD =~ m/^(.*::)(.*)$/); # return if $method eq 'DESTROY'; # # $method =~ s/__/=/g; # $method =~ tr/_=/._/; # # splice(@_, 1, 0, $method); # # goto &call; # } =head1 NAME Frontier::Client - issue Frontier XML RPC requests to a server =head1 SYNOPSIS use Frontier::Client; $server = Frontier::Client->new( I ); $result = $server->call($method, @args); $boolean = $server->boolean($value); $date_time = $server->date_time($value); $base64 = $server->base64($value); $value = $boolean->value; $value = $date_time->value; $value = $base64->value; =head1 DESCRIPTION I is an XML-RPC client over HTTP. I instances are used to make calls to XML-RPC servers and as shortcuts for creating XML-RPC special data types. =head1 METHODS =over 4 =item new( I ) Returns a new instance of I and associates it with an XML-RPC server at a URL. I may be a list of key, value pairs or a hash containing the following parameters: =over 4 =item url The URL of the server. This parameter is required. For example: $server = Frontier::Client->new( 'url' => 'http://betty.userland.com/RPC2' ); =item proxy A URL of a proxy to forward XML-RPC calls through. =item encoding The XML encoding to be specified in the XML declaration of outgoing RPC requests. Incoming results may have a different encoding specified; XML::Parser will convert incoming data to UTF-8. The default outgoing encoding is none, which uses XML 1.0's default of UTF-8. For example: $server = Frontier::Client->new( 'url' => 'http://betty.userland.com/RPC2', 'encoding' => 'ISO-8859-1' ); =item use_objects If set to a non-zero value will convert incoming Ei4E, EfloatE, and EstringE values to objects instead of scalars. See int(), float(), and string() below for more details. =item debug If set to a non-zero value will print the encoded XML request and the XML response received. =back =item call($method, @args) Forward a procedure call to the server, either returning the value returned by the procedure or failing with exception. `C<$method>' is the name of the server method, and `C<@args>' is a list of arguments to pass. Arguments may be Perl hashes, arrays, scalar values, or the XML-RPC special data types below. =item boolean( $value ) =item date_time( $value ) =item base64( $base64 ) The methods `C', `C', and `C' create and return XML-RPC-specific datatypes that can be passed to `C'. Results from servers may also contain these datatypes. The corresponding package names (for use with `C', for example) are `C', `C', and `C'. The value of boolean, date/time, and base64 data can be set or returned using the `C' method. For example: # To set a value: $a_boolean->value(1); # To retrieve a value $base64 = $base64_xml_rpc_data->value(); Note: `C' does I encode or decode base64 data for you, you must use MIME::Base64 or similar module for that. =item int( 42 ); =item float( 3.14159 ); =item string( "Foo" ); By default, you may pass ordinary Perl values (scalars) to be encoded. RPC2 automatically converts them to XML-RPC types if they look like an integer, float, or as a string. This assumption causes problems when you want to pass a string that looks like "0096", RPC2 will convert that to an Ei4E because it looks like an integer. With these methods, you could now create a string object like this: $part_num = $server->string("0096"); and be confident that it will be passed as an XML-RPC string. You can change and retrieve values from objects using value() as described above. =back =head1 SEE ALSO perl(1), Frontier::RPC2(3) =head1 AUTHOR Ken MacLeod =cut 1; libfrontier-rpc-perl-0.07b4.orig/lib/Frontier/Daemon.pm0000644000175000017500000000457007522624106022455 0ustar srzsrz00000000000000# # Copyright (C) 1998 Ken MacLeod # Frontier::Daemon is free software; you can redistribute it # and/or modify it under the same terms as Perl itself. # # $Id: Daemon.pm,v 1.5 2001/10/03 01:30:54 kmacleod Exp $ # # NOTE: see Net::pRPC for a Perl RPC implementation ### ### NOTE: $self is inherited from HTTP::Daemon and the weird access ### comes from there (`${*$self}'). ### use strict; package Frontier::Daemon; use vars qw{@ISA}; @ISA = qw{HTTP::Daemon}; use Frontier::RPC2; use HTTP::Daemon; use HTTP::Status; sub new { my $class = shift; my %args = @_; my $self = $class->SUPER::new(%args); return undef unless $self; ${*$self}{'methods'} = $args{'methods'}; ${*$self}{'decode'} = new Frontier::RPC2 'use_objects' => $args{'use_objects'}; ${*$self}{'response'} = new HTTP::Response 200; ${*$self}{'response'}->header('Content-Type' => 'text/xml'); my $conn; while ($conn = $self->accept) { my $rq = $conn->get_request; if ($rq) { if ($rq->method eq 'POST' && $rq->url->path eq '/RPC2') { ${*$self}{'response'}->content(${*$self}{'decode'}->serve($rq->content, ${*$self}{'methods'})); $conn->send_response(${*$self}{'response'}); } else { $conn->send_error(RC_FORBIDDEN); } } $conn->close; $conn = undef; # close connection } return $self; } =head1 NAME Frontier::Daemon - receive Frontier XML RPC requests =head1 SYNOPSIS use Frontier::Daemon; Frontier::Daemon->new(methods => { 'rpcName' => \&sub_name, ... }); =head1 DESCRIPTION I is an HTTP/1.1 server that listens on a socket for incoming requests containing Frontier XML RPC2 method calls. I is a subclass of I, which is a subclass of I. I takes a `C' parameter, a hash that maps an incoming RPC method name to reference to a subroutine. I takes a `C' parameter that if set to a non-zero value will convert incoming EintE, Ei4E, EfloatE, and EstringE values to objects instead of scalars. See int(), float(), and string() in Frontier::RPC2 for more details. =head1 SEE ALSO perl(1), HTTP::Daemon(3), IO::Socket::INET(3), Frontier::RPC2(3) =head1 AUTHOR Ken MacLeod =cut 1; libfrontier-rpc-perl-0.07b4.orig/lib/Frontier/RPC2.pm0000644000175000017500000004444407522624106021764 0ustar srzsrz00000000000000# # Copyright (C) 1998, 1999 Ken MacLeod # Frontier::RPC is free software; you can redistribute it # and/or modify it under the same terms as Perl itself. # # $Id: RPC2.pm,v 1.18 2002/08/02 18:35:21 ivan420 Exp $ # # NOTE: see Storable for marshalling. use strict; package Frontier::RPC2; use XML::Parser; use vars qw{%scalars %char_entities}; %char_entities = ( '&' => '&', '<' => '<', '>' => '>', '"' => '"', ); # FIXME I need a list of these %scalars = ( 'base64' => 1, 'boolean' => 1, 'dateTime.iso8601' => 1, 'double' => 1, 'int' => 1, 'i4' => 1, 'string' => 1, ); sub new { my $class = shift; my $self = ($#_ == 0) ? { %{ (shift) } } : { @_ }; bless $self, $class; if (defined $self->{'encoding'}) { $self->{'encoding_'} = " encoding=\"$self->{'encoding'}\""; } else { $self->{'encoding_'} = ""; } return $self; } sub encode_call { my $self = shift; my $proc = shift; my @text; push @text, <{'encoding_'}?> $proc EOF push @text, $self->_params([@_]); push @text, < EOF return join('', @text); } sub encode_response { my $self = shift; my @text; push @text, <{'encoding_'}?> EOF push @text, $self->_params([@_]); push @text, < EOF return join('', @text); } sub encode_fault { my $self = shift; my $code = shift; my $message = shift; my @text; push @text, <{'encoding_'}?> EOF push @text, $self->_item({faultCode => $code, faultString => $message}); push @text, < EOF return join('', @text); } sub serve { my $self = shift; my $xml = shift; my $methods = shift; my $call; # FIXME bug in Frontier's XML $xml =~ s/(<\?XML\s+VERSION)/\L$1\E/; eval { $call = $self->decode($xml) }; if ($@) { return $self->encode_fault(1, "error decoding RPC.\n" . $@); } if ($call->{'type'} ne 'call') { return $self->encode_fault(2,"expected RPC \`methodCall', got \`$call->{'type'}'\n"); } my $method = $call->{'method_name'}; if (!defined $methods->{$method}) { return $self->encode_fault(3, "no such method \`$method'\n"); } my $result; my $eval = eval { $result = &{ $methods->{$method} }(@{ $call->{'value'} }) }; if ($@) { return $self->encode_fault(4, "error executing RPC \`$method'.\n" . $@); } my $response_xml = $self->encode_response($result); return $response_xml; } sub _params { my $self = shift; my $array = shift; my @text; my $item; foreach $item (@$array) { push (@text, "", $self->_item($item), "\n"); } return @text; } sub _item { my $self = shift; my $item = shift; my @text; my $ref = ref($item); if (!$ref) { push (@text, $self->_scalar ($item)); } elsif ($ref eq 'ARRAY') { push (@text, $self->_array($item)); } elsif ($ref eq 'HASH') { push (@text, $self->_hash($item)); } elsif ($ref eq 'Frontier::RPC2::Boolean') { push @text, "", $item->repr, "\n"; } elsif ($ref eq 'Frontier::RPC2::String') { push @text, "", $item->repr, "\n"; } elsif ($ref eq 'Frontier::RPC2::Integer') { push @text, "", $item->repr, "\n"; } elsif ($ref eq 'Frontier::RPC2::Double') { push @text, "", $item->repr, "\n"; } elsif ($ref eq 'Frontier::RPC2::DateTime::ISO8601') { push @text, "", $item->repr, "\n"; } elsif ($ref eq 'Frontier::RPC2::Base64') { push @text, "", $item->repr, "\n"; } elsif ($ref =~ /=HASH\(/) { push @text, $self->_hash($item); } elsif ($ref =~ /=ARRAY\(/) { push @text, $self->_array($item); } else { die "can't convert \`$item' to XML\n"; } return @text; } sub _hash { my $self = shift; my $hash = shift; my @text = "\n"; my ($key, $value); while (($key, $value) = each %$hash) { push (@text, "$key", $self->_item($value), "\n"); } push @text, "\n"; return @text; } sub _array { my $self = shift; my $array = shift; my @text = "\n"; my $item; foreach $item (@$array) { push @text, $self->_item($item); } push @text, "\n"; return @text; } sub _scalar { my $self = shift; my $value = shift; # these are from `perldata(1)' if ($value =~ /^[+-]?\d+$/) { return ("$value"); } elsif ($value =~ /^(-?(?:\d+(?:\.\d*)?|\.\d+)|([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?)$/) { return ("$value"); } else { $value =~ s/([&<>\"])/$char_entities{$1}/ge; return ("$value"); } } sub decode { my $self = shift; my $string = shift; $self->{'parser'} = XML::Parser->new( Style => ref($self), 'use_objects' => $self->{'use_objects'} ); return $self->{'parser'}->parsestring($string); } # shortcuts sub base64 { my $self = shift; return Frontier::RPC2::Base64->new(@_); } sub boolean { my $self = shift; my $elem = shift; if($elem == 0 or $elem == 1) { return Frontier::RPC2::Boolean->new($elem); } else { die "error in rendering RPC type \`$elem\' not a boolean\n"; } } sub double { my $self = shift; my $elem = shift; # this is from `perldata(1)' if($elem =~ /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/) { return Frontier::RPC2::Double->new($elem); } else { die "error in rendering RPC type \`$elem\' not a double\n"; } } sub int { my $self = shift; my $elem = shift; # this is from `perldata(1)' if($elem =~ /^[+-]?\d+$/) { return Frontier::RPC2::Integer->new($elem); } else { die "error in rendering RPC type \`$elem\' not an int\n"; } } sub string { my $self = shift; return Frontier::RPC2::String->new(@_); } sub date_time { my $self = shift; return Frontier::RPC2::DateTime::ISO8601->new(@_); } ###################################################################### ### ### XML::Parser callbacks ### sub die { my $expat = shift; my $message = shift; die $message . "at line " . $expat->current_line . " column " . $expat->current_column . "\n"; } sub init { my $expat = shift; $expat->{'rpc_state'} = []; $expat->{'rpc_container'} = [ [] ]; $expat->{'rpc_member_name'} = []; $expat->{'rpc_type'} = undef; $expat->{'rpc_args'} = undef; } # FIXME this state machine wouldn't be necessary if we had a DTD. sub start { my $expat = shift; my $tag = shift; my $state = $expat->{'rpc_state'}[-1]; if (!defined $state) { if ($tag eq 'methodCall') { $expat->{'rpc_type'} = 'call'; push @{ $expat->{'rpc_state'} }, 'want_method_name'; } elsif ($tag eq 'methodResponse') { push @{ $expat->{'rpc_state'} }, 'method_response'; } else { Frontier::RPC2::die($expat, "unknown RPC type \`$tag'\n"); } } elsif ($state eq 'want_method_name') { Frontier::RPC2::die($expat, "wanted \`methodName' tag, got \`$tag'\n") if ($tag ne 'methodName'); push @{ $expat->{'rpc_state'} }, 'method_name'; $expat->{'rpc_text'} = ""; } elsif ($state eq 'method_response') { if ($tag eq 'params') { $expat->{'rpc_type'} = 'response'; push @{ $expat->{'rpc_state'} }, 'params'; } elsif ($tag eq 'fault') { $expat->{'rpc_type'} = 'fault'; push @{ $expat->{'rpc_state'} }, 'want_value'; } } elsif ($state eq 'want_params') { Frontier::RPC2::die($expat, "wanted \`params' tag, got \`$tag'\n") if ($tag ne 'params'); push @{ $expat->{'rpc_state'} }, 'params'; } elsif ($state eq 'params') { Frontier::RPC2::die($expat, "wanted \`param' tag, got \`$tag'\n") if ($tag ne 'param'); push @{ $expat->{'rpc_state'} }, 'want_param_name_or_value'; } elsif ($state eq 'want_param_name_or_value') { if ($tag eq 'value') { $expat->{'may_get_cdata'} = 1; $expat->{'rpc_text'} = ""; push @{ $expat->{'rpc_state'} }, 'value'; } elsif ($tag eq 'name') { push @{ $expat->{'rpc_state'} }, 'param_name'; } else { Frontier::RPC2::die($expat, "wanted \`value' or \`name' tag, got \`$tag'\n"); } } elsif ($state eq 'param_name') { Frontier::RPC2::die($expat, "wanted parameter name data, got tag \`$tag'\n"); } elsif ($state eq 'want_value') { Frontier::RPC2::die($expat, "wanted \`value' tag, got \`$tag'\n") if ($tag ne 'value'); $expat->{'rpc_text'} = ""; $expat->{'may_get_cdata'} = 1; push @{ $expat->{'rpc_state'} }, 'value'; } elsif ($state eq 'value') { $expat->{'may_get_cdata'} = 0; if ($tag eq 'array') { push @{ $expat->{'rpc_container'} }, []; push @{ $expat->{'rpc_state'} }, 'want_data'; } elsif ($tag eq 'struct') { push @{ $expat->{'rpc_container'} }, {}; push @{ $expat->{'rpc_member_name'} }, undef; push @{ $expat->{'rpc_state'} }, 'struct'; } elsif ($scalars{$tag}) { $expat->{'rpc_text'} = ""; push @{ $expat->{'rpc_state'} }, 'cdata'; } else { Frontier::RPC2::die($expat, "wanted a data type, got \`$tag'\n"); } } elsif ($state eq 'want_data') { Frontier::RPC2::die($expat, "wanted \`data', got \`$tag'\n") if ($tag ne 'data'); push @{ $expat->{'rpc_state'} }, 'array'; } elsif ($state eq 'array') { Frontier::RPC2::die($expat, "wanted \`value' tag, got \`$tag'\n") if ($tag ne 'value'); $expat->{'rpc_text'} = ""; $expat->{'may_get_cdata'} = 1; push @{ $expat->{'rpc_state'} }, 'value'; } elsif ($state eq 'struct') { Frontier::RPC2::die($expat, "wanted \`member' tag, got \`$tag'\n") if ($tag ne 'member'); push @{ $expat->{'rpc_state'} }, 'want_member_name'; } elsif ($state eq 'want_member_name') { Frontier::RPC2::die($expat, "wanted \`name' tag, got \`$tag'\n") if ($tag ne 'name'); push @{ $expat->{'rpc_state'} }, 'member_name'; $expat->{'rpc_text'} = ""; } elsif ($state eq 'member_name') { Frontier::RPC2::die($expat, "wanted data, got tag \`$tag'\n"); } elsif ($state eq 'cdata') { Frontier::RPC2::die($expat, "wanted data, got tag \`$tag'\n"); } else { Frontier::RPC2::die($expat, "internal error, unknown state \`$state'\n"); } } sub end { my $expat = shift; my $tag = shift; my $state = pop @{ $expat->{'rpc_state'} }; if ($state eq 'cdata') { my $value = $expat->{'rpc_text'}; if ($tag eq 'base64') { $value = Frontier::RPC2::Base64->new($value); } elsif ($tag eq 'boolean') { $value = Frontier::RPC2::Boolean->new($value); } elsif ($tag eq 'dateTime.iso8601') { $value = Frontier::RPC2::DateTime::ISO8601->new($value); } elsif ($expat->{'use_objects'}) { if ($tag eq 'i4' or $tag eq 'int') { $value = Frontier::RPC2::Integer->new($value); } elsif ($tag eq 'float') { $value = Frontier::RPC2::Float->new($value); } elsif ($tag eq 'string') { $value = Frontier::RPC2::String->new($value); } } $expat->{'rpc_value'} = $value; } elsif ($state eq 'member_name') { $expat->{'rpc_member_name'}[-1] = $expat->{'rpc_text'}; $expat->{'rpc_state'}[-1] = 'want_value'; } elsif ($state eq 'method_name') { $expat->{'rpc_method_name'} = $expat->{'rpc_text'}; $expat->{'rpc_state'}[-1] = 'want_params'; } elsif ($state eq 'struct') { $expat->{'rpc_value'} = pop @{ $expat->{'rpc_container'} }; pop @{ $expat->{'rpc_member_name'} }; } elsif ($state eq 'array') { $expat->{'rpc_value'} = pop @{ $expat->{'rpc_container'} }; } elsif ($state eq 'value') { # the rpc_text is a string if no type tags were given if ($expat->{'may_get_cdata'}) { $expat->{'may_get_cdata'} = 0; if ($expat->{'use_objects'}) { $expat->{'rpc_value'} = Frontier::RPC2::String->new($expat->{'rpc_text'}); } else { $expat->{'rpc_value'} = $expat->{'rpc_text'}; } } my $container = $expat->{'rpc_container'}[-1]; if (ref($container) eq 'ARRAY') { push @$container, $expat->{'rpc_value'}; } elsif (ref($container) eq 'HASH') { $container->{ $expat->{'rpc_member_name'}[-1] } = $expat->{'rpc_value'}; } } } sub char { my $expat = shift; my $text = shift; $expat->{'rpc_text'} .= $text; } sub proc { } sub final { my $expat = shift; $expat->{'rpc_value'} = pop @{ $expat->{'rpc_container'} }; return { value => $expat->{'rpc_value'}, type => $expat->{'rpc_type'}, method_name => $expat->{'rpc_method_name'}, }; } package Frontier::RPC2::DataType; sub new { my $type = shift; my $value = shift; return bless \$value, $type; } # `repr' returns the XML representation of this data, which may be # different [in the future] from what is returned from `value' sub repr { my $self = shift; return $$self; } # sets or returns the usable value of this data sub value { my $self = shift; @_ ? ($$self = shift) : $$self; } package Frontier::RPC2::Base64; use vars qw{@ISA}; @ISA = qw{Frontier::RPC2::DataType}; package Frontier::RPC2::Boolean; use vars qw{@ISA}; @ISA = qw{Frontier::RPC2::DataType}; package Frontier::RPC2::Integer; use vars qw{@ISA}; @ISA = qw{Frontier::RPC2::DataType}; package Frontier::RPC2::String; use vars qw{@ISA}; @ISA = qw{Frontier::RPC2::DataType}; sub repr { my $self = shift; my $value = $$self; $value =~ s/([&<>\"])/$Frontier::RPC2::char_entities{$1}/ge; $value; } package Frontier::RPC2::Double; use vars qw{@ISA}; @ISA = qw{Frontier::RPC2::DataType}; package Frontier::RPC2::DateTime::ISO8601; use vars qw{@ISA}; @ISA = qw{Frontier::RPC2::DataType}; =head1 NAME Frontier::RPC2 - encode/decode RPC2 format XML =head1 SYNOPSIS use Frontier::RPC2; $coder = Frontier::RPC2->new; $xml_string = $coder->encode_call($method, @args); $xml_string = $coder->encode_response($result); $xml_string = $coder->encode_fault($code, $message); $call = $coder->decode($xml_string); $response_xml = $coder->serve($request_xml, $methods); $boolean_object = $coder->boolean($boolean); $date_time_object = $coder->date_time($date_time); $base64_object = $coder->base64($base64); $int_object = $coder->int(42); $float_object = $coder->float(3.14159); $string_object = $coder->string("Foo"); =head1 DESCRIPTION I encodes and decodes XML RPC calls. =over 4 =item $coder = Frontier::RPC2->new( I ) Create a new encoder/decoder. The following option is supported: =over 4 =item encoding The XML encoding to be specified in the XML declaration of encoded RPC requests or responses. Decoded results may have a different encoding specified; XML::Parser will convert decoded data to UTF-8. The default encoding is none, which uses XML 1.0's default of UTF-8. For example: $server = Frontier::RPC2->new( 'encoding' => 'ISO-8859-1' ); =item use_objects If set to a non-zero value will convert incoming Ei4E, EfloatE, and EstringE values to objects instead of scalars. See int(), float(), and string() below for more details. =back =item $xml_string = $coder->encode_call($method, @args) `C' converts a method name and it's arguments into an RPC2 `C' element, returning the XML fragment. =item $xml_string = $coder->encode_response($result) `C' converts the return value of a procedure into an RPC2 `C' element containing the result, returning the XML fragment. =item $xml_string = $coder->encode_fault($code, $message) `C' converts a fault code and message into an RPC2 `C' element containing a `C' element, returning the XML fragment. =item $call = $coder->decode($xml_string) `C' converts an XML string containing an RPC2 `C' or `C' element into a hash containing three members, `C', `C', and `C'. `C' is one of `C', `C', or `C'. `C' is array containing the parameters or result of the RPC. For a `C' type, `C' contains call's parameters and `C' contains the method being called. For a `C' type, the `C' array contains call's result. For a `C' type, the `C' array contains a hash with the two members `C' and `C'. =item $response_xml = $coder->serve($request_xml, $methods) `C' decodes `C<$request_xml>', looks up the called method name in the `C<$methods>' hash and calls it, and then encodes and returns the response as XML. =item $boolean_object = $coder->boolean($boolean); =item $date_time_object = $coder->date_time($date_time); =item $base64_object = $coder->base64($base64); These methods create and return XML-RPC-specific datatypes that can be passed to the encoder. The decoder may also return these datatypes. The corresponding package names (for use with `C', for example) are `C', `C', and `C'. You can change and retrieve the value of boolean, date/time, and base64 data using the `C' method of those objects, i.e.: $boolean = $boolean_object->value; $boolean_object->value(1); Note: `C' does I encode or decode base64 data for you, you must use MIME::Base64 or similar module for that. =item $int_object = $coder->int(42); =item $float_object = $coder->float(3.14159); =item $string_object = $coder->string("Foo"); By default, you may pass ordinary Perl values (scalars) to be encoded. RPC2 automatically converts them to XML-RPC types if they look like an integer, float, or as a string. This assumption causes problems when you want to pass a string that looks like "0096", RPC2 will convert that to an Ei4E because it looks like an integer. With these methods, you could now create a string object like this: $part_num = $coder->string("0096"); and be confident that it will be passed as an XML-RPC string. You can change and retrieve values from objects using value() as described above. =back =head1 SEE ALSO perl(1), Frontier::Daemon(3), Frontier::Client(3) =head1 AUTHOR Ken MacLeod =cut 1; libfrontier-rpc-perl-0.07b4.orig/lib/Frontier/Responder.pm0000644000175000017500000001221307522624106023204 0ustar srzsrz00000000000000# File: Repsonder.pm # based heavily on Ken MacLeod's Frontier::Daemon # Author: Joe Johnston 7/2000 # Revisions: # 11/2000 - Cleaned/Add POD. Took out 'use CGI'. # # Meant to be called from a CGI process to answer client # requests and emit the appropriate reponses. See POD for details. # # LICENSE: This code is released under the same licensing # as Perl itself. # # Use the code where ever you want, but due credit is appreciated. package Frontier::Responder; use strict; use vars qw/@ISA/; use Frontier::RPC2; my $snappy_answer = "Hey, I need to return true, don't I?"; # Class constructor. # Input: (expects parameters to be passed in as a hash) # methods => hashref, keys are API procedure names, values are # subroutine references # # Output: blessed reference sub new { my $class = shift; my %args = @_; my $self = bless {}, (ref $class ? ref $class : $class); # Store the dispatch table away for future use. $self->{methods} = $args{methods}; $self->{_decode} = Frontier::RPC2->new(); return $self; } # Grabs input from CGI "stream", makes request # if possible, packs up the response in purddy # XML # Input: None # Output: A XML string suitable for printing from a CGI process sub answer{ my $self = shift; # fetch the xml message sent my $request = get_cgi_request(); unless( defined $request ){ print "Content-Type: text/txt\n\n"; exit; } # Let's figure out the method to execute # along with its arguments my $response = $self->{_decode}->serve( $request, $self->{methods} ); # Ship it! return "Content-Type: text/xml \n\n" . $response; } # private function. No need to advertise this. # Remember, this is just XML. # CGI.pm doesn't grok this. sub get_cgi_request{ my $in; if( $ENV{REQUEST_METHOD} eq 'POST' ){ my $len = $ENV{CONTENT_LENGTH}; unless ( read( STDIN, $in, $len ) == $len ){ return; } }else{ $in = $ENV{QUERY_STRING}; } return $in; } =pod =head1 NAME Frontier::Responder - Create XML-RPC listeners for normal CGI processes =head1 SYNOPSIS use Frontier::Responder; my $res = Frontier::Responder->new( methods => { add => sub{ $_[0] + $_[1] }, cat => sub{ $_[0] . $_[1] }, }, ); print $res->answer; =head1 DESCRIPTION Use I whenever you need to create an XML-RPC listener using a standard CGI interface. To be effective, a script using this class will often have to be put a directory from which a web server is authorized to execute CGI programs. An XML-RPC listener using this library will be implementing the API of a particular XML-RPC application. Each remote procedure listed in the API of the user defined application will correspond to a hash key that is defined in the C method of a I object. This is exactly the way I works as well. In order to process the request and get the response, the C method is needed. Its return value is XML ready for printing. For those new to XML-RPC, here is a brief description of this protocol. XML-RPC is a way to execute functions on a different machine. Both the client's request and listeners response are wrapped up in XML and sent over HTTP. Because the XML-RPC conversation is in XML, the implementation languages of the server (here called a I), and the client can be different. This can be a powerful and simple way to have very different platforms work together without acrimony. Implicit in the use of XML-RPC is a contract or API that an XML-RPC listener implements and an XML-RPC client calls. The API needs to list not only the various procedures that can be called, but also the XML-RPC datatypes expected for input and output. Remember that although Perl is permissive about datatyping, other languages are not. Unforuntately, the XML-RPC spec doesn't say how to document the API. It is recomended that the author of a Perl XML-RPC listener should at least use POD to explain the API. This allows for the programmatic generation of a clean web page. =head1 METHODS =over 4 =item new( I ) This is the class constructor. As is traditional, it returns a blessed reference to a I object. It expects arguments to be given like a hash (Perl's named parameter mechanism). To be effective, populate the C parameter with a hashref that has API procedure names as keys and subroutine references as values. See the SYNOPSIS for a sample usage. =item answer() In order to parse the request and execute the procedure, this method must be called. It returns a XML string that contains the procedure's response. In a typical CGI program, this string will simply be printed to STDOUT. =back =head1 SEE ALSO perl(1), Frontier::RPC2(3) =head1 AUTHOR Ken MacLeod wrote the underlying RPC library. Joe Johnston wrote an adaptation of the Frontier::Daemon class to create this CGI XML-RPC listener class. =cut libfrontier-rpc-perl-0.07b4.orig/test.pl0000644000175000017500000000161706514556430017675 0ustar srzsrz00000000000000# # Copyright (C) 1998 Ken MacLeod # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. # # $Id: test.pl,v 1.1.1.1 1998/04/14 03:50:48 ken Exp $ # # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### We start with some black magic to print on failure. # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) BEGIN { $| = 1; print "1..1\n"; } END {print "not ok 1\n" unless $loaded;} use Frontier::Client; use Frontier::RPC2; use Frontier::Daemon; $loaded = 1; print "ok 1\n"; ######################### End of black magic. # Insert your test code below (better if it prints "ok 13" # (correspondingly "not ok 13") depending on the success of chunk 13 # of the test code):