/usr/share/perl5/DIME/Tools.pm is in libdime-tools-perl 0.04-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | # Copyright (C) 2004 Domingo Alcázar Larrea
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the version 2 of the GNU General
# Public License as published by the Free Software Foundation.
#
# 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
package DIME::Tools;
$DIME::Tools::VERSION = '0.04';
use 5.008;
use strict;
use warnings;
1;
=encoding UTF-8
=head1 NAME
DIME::Tools - modules for parsing and generate DIME messages
=head1 SYNOPSIS
This is a collection of modules for processing DIME messages.
It hasn't been actively developed since 2004,
and the release in 2016 was to get the distribution following
CPAN conventions, as there is one distribution depending on it.
Generating DIME messages
========================
my $payload = DIME::Payload->new();
$payload->attach(Path => "/mydata/index.html",
MIMEType => 'text/html',
Dynamic => 1);
my $payload2 = DIME::Payload->new();
$payload2->attach( Data => "HELLO WORLD!!!",
MIMEType => 'text/plain' );
my $message = DIME::Message->new();
my $payload = DIME::Payload->new();
$payload->attach(Path => "/mydata/index.html",
MIMEType => 'text/html',
Dynamic => 1);
$message->add_payload($payload);
$message->add_payload($payload2);
# Print the encoded message to STDOUT
$message->print(\*STDOUT);
Parsing DIME messages
=====================
my $parser = DIME::Parser->new();
# Open a file with a dime encoded message
$f = IO::File->new("dime.message","r");
my $message = $parser->parse($f);
$f->close();
# Print the content of each payload to STDOUT
for my $i ($message->payloads())
{
print $i->print_content(\*STDOUT);
}
=head1 DESCRIPTION
DIME-tools is a collection of DIME:: modules for parse and generate DIME encoded messages ( Direct Internet Message Encapsulation ). DIME-tools support single-record and chunked payloads for sending big attachments.
=head1 GENERATING MESSAGES
For any content you want to send in a message, you have to create a Payload object:
my $payload = DIME::Payload->new();
$payload->attach(Path => "/mydata/index.html",
MIMEType => 'text/html',
Dynamic => 1);
With the attach method you can specify the next keys:
Path: the name of the file you want to attach to the payload object. If the data you want to attach isn't in a file, you can use the Data key.
Data: it's the reference to a scalar in which you store the data you want to attach.
Dynamic: if Path is declared, the data is not loaded fully in memory. The only that you attach to the payload object is the name of the file of the Path key, not the content itself.
Chunked: if it's declared, it represents the size of the chunk records in bytes. If you don't declare it, the message will not be chunked.
MIMEType: the type of the payload. It must be a string with a MIME standard type. Other possibility is to use URIType.
URIType: specifies an URI that defines that type of the content.
=head1 ATTACH A PAYLOAD TO A MESSAGE
my $message = DIME::Message->new();
$message->add_payload($payload);
=head1 PRINT A ENCODED MESSAGE
# Print prints to any IO::Handle
$message->print(\*STDOUT);
or
# print_data returns a reference to a scalar
print ${$message->print_data()};
=head1 PARSING MESSAGES
All you have to do is create a DIME::Parser object and call the parse method with a IO::Handle to a DIME message. Then you can iterate over the $message->payloads() array to get the contents of the message:
my $parser = DIME::Parser->new();
$f = IO::File->new("dime.message","r");
my $message = $parser->parse($f);
$f->close();
for my $i ($message->payloads())
{
print $i->print_content(\*STDOUTs);
}
You can also call to parse_data if you have a DIME message in a scalar variable:
my $dime_message;
my $message = $parser->parse_data(\$dime_message);
And call print_content_data if what you want is to get a reference to the content-data.
=head1 SEE ALSO
Direct Internet Message Encapsulation draft:
http://www.gotdotnet.com/team/xml_wsspecs/dime/dime.htm
DIME::Message
DIME::Payload
DIME::Record
=head1 AUTHOR
Domingo Alcazar Larrea, E<lt>dalcazar@cpan.orgE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2004 Domingo Alcázar Larrea
This program is free software; you can redistribute it and/or
modify it under the terms of the version 2 of the GNU General
Public License as published by the Free Software Foundation.
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
=cut
|