wesnoth/utils/campaign_delete.pl
Eric S. Raymond 69f3aa45e8 Move WML-hacking tools from top-level utils directory to data/tools.
This is a clutter-reduction step, separating the packaging and code-integrity 
checks from the stuff for maintaining mainline campaigns.

I've also added documentation comments to some scripts.
2007-04-06 00:02:43 +00:00

48 lines
843 B
Perl
Executable File

#!/usr/bin/perl
#
# Delete a specified campaign from the campaign server.
use wml;
use wml_net;
use strict;
my ($host, $port) = ("campaigns.wesnoth.org", 15003);
$| = 1;
print "Campaign name to be deleted: ";
my $name = <STDIN>;
chomp $name;
print "Passphrase: ";
my $old = <STDIN>;
chomp $old;
my $socket = &wml_net::connect($host,$port);
if (!defined($socket)) {
print "Error connecting to the campaign server\n";
exit;
}
&wml_net::write_packet($socket,&wml::read_text( << "EOF" ));
[delete]
name=\"$name\"
passphrase=\"$old\"
[/delete]
EOF
my $response = &wml_net::read_packet($socket);
if (!defined($response)) {
print "Error accessing the campaign server.\n";
exit;
}
if (my $error = &wml::has_child($response, 'error')) {
printf "Error: %s\n", $error->{'attr'}->{'message'};
exit;
}
print "Campaign deleted.\n";