+################################################################################
+#
+# Version check
+#
+$VERSION = do { my @r =(q$Revision$ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+
+################################################################################
+#
+# Export
+#
+use constant SORT_ASCENT => 0; # (latest postings first)
+use constant SORT_DESCENT => 1;
+use constant KEEP_DELETED => 1;
+use constant KILL_DELETED => 0;
+
+use base qw(Exporter);
+@EXPORT_OK = qw(
+ get_message_header
+ get_message_body
+ get_message_node
+ get_body_node
+ parse_single_thread
+ parse_xml_file
+ create_new_thread
+ create_message
+
+ hr_time
+ short_hr_time
+ long_hr_time
+ very_short_hr_time
+ month
+
+ get_all_threads
+ create_forum_xml_string
+
+ save_file
+
+ SORT_ASCENT
+ SORT_DESCENT
+ KEEP_DELETED
+ KILL_DELETED
+);
+
+################################################################################
+#
+# Access via XML::DOM
+#
+
+### sub create_message ($$) ####################################################
+#
+# create the 'Message' subtree
+#
+# Params: $xml - XML::DOM::Document object
+# $par - hash reference
+# (msg, ip, name, email, home, image, category, subject, time)
+#
+# Return: XML::DOM::Element object
+#
+sub create_message ($$) {
+ my ($xml,$par) = @_;
+
+ my $message = $xml -> createElement ('Message');
+ $message -> setAttribute ('id' => $par -> {msg});
+ $message -> setAttribute ('ip' => $par -> {ip});
+
+ my $header = $xml -> createElement ('Header');
+ my $author = $xml -> createElement ('Author');
+ $header -> appendChild ($author);
+
+ my @may = (
+ ['name' => 'Name' => $author],
+ ['email' => 'Email' => $author],
+ ['home' => 'HomepageUrl' => $author],
+ ['image' => 'ImageUrl' => $author],
+ ['category' => 'Category' => $header],
+ ['subject' => 'Subject' => $header]
+ );# key => element name => superior
+
+ for (@may) {
+
+ # create element
+ my $obj = $xml -> createElement ($_->[1]);
+
+ # insert content
+ $obj -> addText (
+ defined $par -> {$_->[0]}
+ ? $par -> {$_->[0]}
+ : ''
+ );
+
+ # link to superior element
+ $_ -> [2] -> appendChild ($obj);
+ }
+
+ my $date = $xml -> createElement ('Date');
+ $date -> setAttribute ('longSec'=> $par -> {time});
+
+ $header -> appendChild ($date);
+ $message -> appendChild ($header);