libcgi-xml-perl-0.1.orig/0042775000175000017500000000000007005326730013746 5ustar ardoardolibcgi-xml-perl-0.1.orig/Changes0100664000175000017500000000104007005325040015220 0ustar ardoardoRevision history for Perl extension XML::CGI. 0.01 Sat Oct 17 13:14:46 1998 - original version; created by h2xs 1.18 0.02 Mon Oct 19 - Major contribution by David Black which gets rid of local context crud, allows user to specify the root element in XML::CGI::toXML, and all-around improvements. 0.1 Sun Jan 10 03:49:36 EST 1999 - Updated routine to encode characters in x80-xFF range to Unicode. Also added encoding for complete set of pre-declared entities. libcgi-xml-perl-0.1.orig/MANIFEST0100664000175000017500000000014507005325040015063 0ustar ardoardoXML.pm Changes MANIFEST Makefile.PL test.pl examples/cgi2xml.pl examples/cgi.xml examples/xml2cgi.pl libcgi-xml-perl-0.1.orig/Makefile.PL0100664000175000017500000000021507005325040015702 0ustar ardoardouse ExtUtils::MakeMaker; WriteMakefile( NAME => 'CGI::XML', VERSION_FROM => 'XML.pm', PREREQ_PM => { XML::Parser => '2.16' } ); libcgi-xml-perl-0.1.orig/README0100664000175000017500000000143107005325040014611 0ustar ardoardoCopyright (c) 1998 Jonathan Eisenzopf. All rights reserved. This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself. NAME XML::CGI Version 0.1 DESCRIPTION The XML::CGI module converts CGI.pm variables from/to XML. Feel free to contact me at eisen@pobox.com if you have problems and/or suggestions. REQUIREMENTS This module requires version 2.16 or greater of the XML::Parser module. The latest version is available at any CPAN archive. You will also need CGI.pm version 2.37 or greater or CGI::XML won't work. INSTALLATION perl Makefile.PL make make install CREDITS David Alan Black Matthew Sergeant Francois Belanger Enno Derksen libcgi-xml-perl-0.1.orig/XML.pm0100664000175000017500000000546107005325040014736 0ustar ardoardopackage CGI::XML; use strict; use CGI; use vars qw($VERSION @ISA $self $parser); use XML::Parser; @ISA = qw(CGI); $VERSION = '0.1'; sub toXML { my ($self,$root) = @_; my $xml = join "\n", (map { "<$_>" . &QuoteXMLChars($self->param($_)) . "" } $self->param), ""; return $root ? "<$root>\n$xml\n" : $xml; } sub toCGI { my ($self, $xml) = @_; my $root; my $parser = new XML::Parser(Handlers => {Char => $self->handle_char}); $parser->parse($xml); } sub handle_char { my $self = shift; return sub { my ($parser,$cdata) = @_; return if $parser->depth == 1; my $element = $parser->current_element; $self->delete($element); unshift @{$self->param_fetch(-name=>$element)},$cdata; } } sub QuoteXMLChars { $_[0] =~ s/&/&/g; $_[0] =~ s//>/g; $_[0] =~ s/'/'/g; $_[0] =~ s/"/"/g; $_[0] =~ s/([\x80-\xFF])/&XmlUtf8Encode(ord($1))/ge; return($_[0]); } sub XmlUtf8Encode { # borrowed from XML::DOM my $n = shift; if ($n < 0x80) { return chr ($n); } elsif ($n < 0x800) { return pack ("CC", (($n >> 6) | 0xc0), (($n & 0x3f) | 0x80)); } elsif ($n < 0x10000) { return pack ("CCC", (($n >> 12) | 0xe0), ((($n >> 6) & 0x3f) | 0x80), (($n & 0x3f) | 0x80)); } elsif ($n < 0x110000) { return pack ("CCCC", (($n >> 18) | 0xf0), ((($n >> 12) & 0x3f) | 0x80), ((($n >> 6) & 0x3f) | 0x80), (($n & 0x3f) | 0x80)); } return $n; } 1; __END__ =head1 NAME XML::CGI - Perl extension for converting CGI.pm variables to/from XML =head1 SYNOPSIS use XML::CGI; $q = new XML::CGI; # convert CGI.pm variables to XML $xml = $q->toXML; $xml = $q->toXML($root); # convert XML to CGI.pm variables $q->toCGI($xml); =head1 DESCRIPTION The XML::CGI module converts CGI.pm variables to XML and vice versa. B is a subclass of B, so it reads the CGI variables just as CGI.pm would. =head1 METHODS =item $q = new XML::CGI =over 4 creates a new instance of XML::CGI. You also have access to all of the methods in CGI.pm. =back =item $q->toXML([$root]) =over 4 where B<$root> is an optional parameter that specifies the root element. By default, B will not return a root element. =back =item $q->toCGI($xml) =over 4 where B<$xml> is the XML you would like to convert to CGI.pm parameters. Values in the XML will overwrite any existing values if they exist. =back =head1 NOTE B does not currently handle multiple selections passed from HTML forms. This will be added in a future release. =head1 AUTHOR Jonathan Eisenzopf =head1 CONTRIBUTORS David Black =head1 SEE ALSO perl(1), XML::Parser(3). =cut libcgi-xml-perl-0.1.orig/test.pl0100664000175000017500000000065707005325040015256 0ustar ardoardo# 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 XML::CGI; $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): libcgi-xml-perl-0.1.orig/examples/0042775000175000017500000000000007005326730015564 5ustar ardoardolibcgi-xml-perl-0.1.orig/examples/cgi.xml0100664000175000017500000000007607005325040017037 0ustar ardoardo
Jonathan Eisenzopf bum
libcgi-xml-perl-0.1.orig/examples/cgi2xml.pl0100775000175000017500000000021507005325040017453 0ustar ardoardo#!/usr/bin/perl -w use strict; use CGI::XML; my $q = new CGI::XML; # save CGI variables to XML file my $xml = $q->toXML("cgi"); print $xml; libcgi-xml-perl-0.1.orig/examples/xml2cgi.pl0100775000175000017500000000041707005325040017457 0ustar ardoardo#!/usr/bin/perl -w use strict; use CGI::XML; my $q = new CGI::XML; # load CGI variables from XML file open (XML,"cgi.xml"); my $xml = join("",); $q->toCGI($xml); # print CGI variables foreach my $item ($q->param) { print "$item = ", $q->param($item), "\n"; }