+
+sub get_comment {
+ my ($format, $username, $subject, $date, $url, $email, $ip, $content) = @_;
+ $format = defined $format ? $format = " format=$format" : q{};
+ $content = '' unless defined $content;
+ my $comment="[[!comment$format\n";
+ $comment.=" username=\"$username\"\n";
+ $comment.=" subject=\"\"\"$subject\"\"\"\n";
+ $comment.=" date=\"$date\"\n";
+ $comment.=" url=\"$url\"\n" if defined $url;
+ $comment.=" email=\"$email\"\n" if defined $email;
+ $comment.=" ip=\"$ip\"\n" if defined $ip;
+ $comment.=" content=\"\"\"\n$content\n\"\"\"]]\n";
+ return $comment;
+}
+
+sub exec_editor {
+ my ($file) = @_;
+
+ my @editor="vi";
+ if (-x "/usr/bin/editor") {
+ @editor="/usr/bin/editor";
+ }
+ if (exists $ENV{EDITOR}) {
+ @editor=split(' ', $ENV{EDITOR});
+ }
+ if (exists $ENV{VISUAL}) {
+ @editor=split(' ', $ENV{VISUAL});
+ }
+ exec(@editor, $file);
+}
+
+main(@ARGV);